npm.io
0.1.0 • Published 8 years ago

speedmetrics

Licence
MIT
Version
0.1.0
Deps
2
Size
9 kB
Vulns
0
Weekly
0

travis codecov

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)
})

Keywords