This repository has been archived by the owner on Aug 10, 2023. It is now read-only.
Add measure function
measure
Wrap a function and measure it's execution time in milliseconds into a performance measure entry.
import { measure } from 'page-timing';
await pageTiming.measure(wait, 'my-function');
// Example: Convert entries to a named array
performance.getEntriesByType('measure').reduce(
(accumulator, {name, duration}) => Object.assign(accumulator, {[name]: duration}),
{}
);
// {my-function: 53.35999990347773}
// Example: Retrieve a specific entry
const { duration } = performance.getEntriesByType('measure')
.find(({name}) => name === 'my-function');
// 53.35999990347773