performance.now()

The Performance.now() method returns a DOMHighResTimeStamp, measured in milliseconds, accurate to one thousandth of a millisecond.

https://developer.mozilla.org/en-US/docs/Web/API/Performance/now

  • In any context, the value is the value from t0 of the main context (the PerformanceTiming.navigationStart property) — main context, or any type of worker spawned from the main context (or another worker.)
  • In dedicated workers created from a Window context, 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 t0 of 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.')