chrome-timeline
Write performance tests and get the timeline profiling data from puppeteer (chromium).
Example:
const timeline = require('chrome-timeline').timeline;
timeline(async (runner) => {
await runner.page.goto('https://example.com');
await runner.tracingStart('TRACE_ABC');
await runner.remote((done, window) => {
some_heavy_stuff_to_be_measured();
done();
setTimeout(done, 10000);
});
await runner.tracingStop();
});
By default timeline
does a clean startup of a remote puppeteer chromium client,
runs the provided callback and exists the client afterwards.
This behavior can be changed by providing custom options (e.g. connecting to a running remote instance).
timeline
returns a promise containing summaries of tracings that were done denoted
by the name ('TRACE_ABC'
in the example).
Tracing start default options
tracingStartOptions: {
path: null,
screenshots: true,
categories: [
'-*',
'v8.execute',
'blink.user_timing',
'latencyInfo',
'devtools.timeline',
'disabled-by-default-devtools.timeline',
'disabled-by-default-devtools.timeline.frame',
'toplevel',
'blink.console',
'disabled-by-default-devtools.timeline.stack',
'disabled-by-default-devtools.screenshot',
'disabled-by-default-v8.cpu_profile',
'disabled-by-default-v8.cpu_profiler',
'disabled-by-default-v8.cpu_profiler.hires'
]
}
Tracing end default options
tracingEndOptions: {
saveTrace: false,
createSummary: true,
reportUncommittedChanges: false,
}
Summary
Summaries are returned by timeline
for a single tracing, if tracingEndOptions.createSummary=true
.
They contain various useful stats from a trace for further postprocessing:
export interface ISummary extends IPostProcess {
traceFile: string;
traceName: string;
repo: IRepoInfo;
metadata: {[key: string]: any};
summary: {[key: string]: number};
topDown: IEvent[];
bottomUp: IEvent[];
}