speedmetrics
v0.1.0
Published
Collect meaningful metrics from Chrome's trace events.
Downloads
2
Maintainers
Readme
Collect meaningful metrics from Chrome's trace events.
Quickstart
Installation
npm install speedmetrics
Usage
import collectMetrics from 'speedmetrics'
const metrics = await collectMetrics('trace.json')
console.log(metrics)
{
timings: {
navigationStart: 0,
domContentLoaded: 200,
firstPaint: 400,
firstContentfulPaint: 400,
firstMeaningfulPaint: 600,
load: 1000
}
events: {
/* ... */
}
}
API
metrics(filename)
Loads a trace file name and return a promise resolving to collected metrics.
const metrics = await collectMetrics('trace.json')
metrics(traceEvents)
Accepts a trace events object and return a promise resolving to collected metrics.
readFile('trace.json', 'utf8', async (err, data) => {
const metrics = await collectMetrics(data.traceEvents)
})