Expand description
performance: High Resolution Time, User Timing and the Performance
Timeline.
now() reads a monotonic Instant, never the wall clock. That is
the whole point of the API — a Date.now() delta can go backwards
when NTP steps the clock mid-measurement, and a timing number that
silently goes backwards is worse than no timing number. The wall
clock appears exactly once, as timeOrigin, which is what the
monotonic readings are relative to.
monotonic_base is also what process.hrtime counts from, so the
two clocks are correlatable the way Node’s are (both derive from one
libuv hrtime there).
Covered: now, timeOrigin, toJSON, mark, measure,
clearMarks, clearMeasures, getEntries, getEntriesByName,
getEntriesByType, and the PerformanceEntry / PerformanceMark /
PerformanceMeasure classes with PerformanceEntry as their
prototype, so mark instanceof PerformanceEntry holds.
Not covered: PerformanceObserver (it needs a task-queue hook this
runtime has no equivalent of), the resource/navigation timing entry
types (no document), and Node’s eventLoopUtilization / nodeTiming.
A buffer size limit is not implemented either; nothing here evicts,
so a program marking in a hot loop grows the buffer until it calls
clearMarks, exactly as the spec’s maxBufferSize exists to bound.
Structs§
- Performance
Entry Js PerformanceEntry— the base every timeline entry reads as.- Performance
Js performance.- Performance
Mark Js PerformanceMark— aPerformanceEntryplus thedetailits creator attached.- Performance
Measure Js PerformanceMeasure— an interval between two points on the timeline.
Functions§
- init
- Define the four classes and install the
performanceinstance. - monotonic_
base - The process-wide monotonic origin.
process.hrtimecounts from this too, so a script can line its readings up againstperformance.now(). - now_ms
performance.now()in fractional milliseconds.- time_
origin_ ms performance.timeOrigin: Unix-epoch milliseconds at the monotonic base.