Analyze tracelogs from Chrome, from the command line or as a node.js library.
With node.js >= 8.9 and npm >= 5.3, use npx to run chrome-trace.
npx chrome-trace <trace file>
Install chrome-trace as a dependency.
npm i chrome-trace Pass a stream or a parsed JSON object to chrome-trace.
const{ parseStream }=require('chrome-trace');conststream=getReadableStream();// e.g. stream from file or http responseconstparsedTrace=parseStream(stream);constmainThreadId=parsedTrace.mainThread;constcategories=parsedTrace.eventCategoryTime[mainThreadId];console.log(categories);- The format for trace-log events is described here.
- A python parser for tracelogs is available from WPO Foundation.
- Chrome-trace uses Ava for testing. Please run
npm run testbefore submitting PRs. - Code formatting by Prettier. Please run
npm run lint:fixbefore submitting PRs. - Optional verbose logging using the debug module.
- Additional useful npm scripts are:
test:verbosefor additional debug infotest:watchto rerun tests as changes are madetest:watch:verboseautomatic testing, with debug output