Performance.now() method returns a
DOMHighResTimeStamp, measured in milliseconds, accurate to one thousandth of a millisecond.
- In any context, the value is the value from
t0of the main context (the
PerformanceTiming.navigationStartproperty) — main context, or any type of worker spawned from the main context (or another worker.)
- In dedicated workers created from a
Windowcontext, the value in the worker will be lower than
performance.now()in the window who spawned that worker. It used to be the same as
t0of the main context, but this was changed.
- In shared or service workers, the value in the worker might be higher than that of the main context because that window can be created after those workers.
var t0 = performance.now(); doSomething(); var t1 = performance.now(); console.log('Call to doSomething took ' + (t1 - t0) + ' milliseconds.')