performance.measure(), providing high-resolution
timings as well as nice Dev Tools visualizations.
For browsers that don't support
performance.mark(), it falls back to
Date.now(). In Node, it uses
Install via npm:
npm install marky
Or as a script tag:
Then take some measurements:
var marky = ;marky;;marky;
As well as Edge F12 Tools:
This is because
marky adds standard
PerformanceEntries to the Performance Timeline. Tools like WebPageTest and Windows Performance Analyzer also surface them, and you can even send them to your analytics provider.
marky.mark() begins recording, and
marky.stop() finishes recording:
You can also do more complex scenarios:
marky.stop() also returns a
marky;;var entry = marky;
The entry will look something like:
You can get all entries using:
var entries = marky;
This provides a list of all measures ordered by
You can also clear the entries using
marky.getEntries() will return an empty list. (If the User Timing API is supported, this will delete all the
measure entries from the timeline.)
marky is tested in the following browsers/environments:
- IE 9+
- Safari 8+
- iOS 8+
- Android 4.4+
- Node 4+
Per the spec, browsers only need to hold a minimum
of 150 entries in their Performance Timeline buffer. Notably Firefox throttles their buffer to 150, which for
means you can get a maximum of 50 entries from
marky creates two marks and a measure).
If you need to get more than 50 entries from
marky.getEntries(), you can do:
if typeof performance !== 'undefined' && performancesetResourceTimingBufferSizeperformance; // or however many you need
In Node and browsers that don't support the User Timing API,
marky follows the behavior of Edge and Chrome, and does not limit the number of entries.
marky.getEntries() will return pseudo-
- appmetrics.js – a library on top of
measure()which reports to Google Analytics.
Thanks to @toddreifsteck for feedback on this project and clarifications on the User Timing API.