BOOMR.plugins. UserTiming


The UserTiming plugin to collect metrics from the W3C UserTiming API.

This plugin is dependent on the UserTimingCompression library. UserTimingCompression must be loaded before this plugin's init() is called.

This plugin collects all marks and measures that were added since navigation start or since the last beacon fired for the current navigation.

For information on how to include this plugin, see the Building tutorial.

Beacon Parameters

This plugin adds the following parameters to the beacon:

  • usertiming: Compressed ResourceTiming data

The value is a compressed string using UserTimingCompression library. A decompression function is also available in the library.

Timing data is rounded to the nearest millisecond.

Example

// mark current timestamp as mark1
performance.mark('mark1');
// mark current timestamp as mark1
performance.mark('mark2');
// measure1 will be the delta between mark1 and mark2 timestamps
performance.measure('measure1', 'mark1', 'mark2');
//measure2 will be the delta between the mark2 timestamp and the current time
performance.measure('measure2', 'mark2');

The compressed data added to the beacon will look similar to the following:

usertiming=~(m~(ark~(1~'2s~2~'5k)~easure~(1~'2s_2s~2~'5k_5k)))

Decompressing the above value will give us the original data for the marks and measures collected:

[{"name":"mark1","startTime":100,"duration":0,"entryType":"mark"},
{"name":"measure1","startTime":100,"duration":100,"entryType":"measure"},
{"name":"mark2","startTime":200,"duration":0,"entryType":"mark"},
{"name":"measure2","startTime":200,"duration":200,"entryType":"measure"}]

Compatibility

Many browsers support the UserTiming API, e.g.:

  • Chrome 25+
  • Edge
  • Firefox 38+
  • IE 10+
  • Opera 15+

See Nic Jansma's usertiming.js polyfill library to add UserTiming API support for browsers that don't implement it natively.

See:

Methods


init()

Initializes the plugin.

Returns:

BOOMR.plugins.UserTiming The UserTiming plugin for chaining


is_complete()

Whether or not this plugin is complete

Returns:

Type: boolean

true if the plugin is complete


is_supported()

Whether or not UserTiming is supported in this browser.

Returns:

Type: boolean

true if UserTiming is supported.