Skip to main content

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 check
  • now() โ€” high-resolution timestamp in ms, falls back to Date.now()
  • getPerformanceEntriesByType(type) โ€” entries of a given type (e.g. 'resource', 'mark')
  • mark(name) โ€” records a named timestamp
  • measure(name, startMark, endMark) โ€” records the duration between two marks

See the API reference for full signatures.