performance
Timestamps, marks, and measures via the Performance API, with a Date.now() fallback.
Import: @rtorcato/browser-common/performance
๐ MDN: Performance API ยท ๐ caniuse: user-timing
Exampleโ
import { isPerformanceApiAvailable, now, mark, measure } from '@rtorcato/browser-common/performance'
if (isPerformanceApiAvailable()) {
mark('boot-start')
const start = now()
doWork()
mark('boot-end')
measure('boot', 'boot-start', 'boot-end')
}
Exportsโ
isPerformanceApiAvailable()โ feature checknow()โ high-resolution timestamp in ms, falls back toDate.now()getPerformanceEntriesByType(type)โ entries of a given type (e.g.'resource','mark')mark(name)โ records a named timestampmeasure(name, startMark, endMark)โ records the duration between two marks
See the API reference for full signatures.