The returned value represents the time elapsed since the time origin.
const t0 = performance.now();
doSomething();
const t1 = performance.now();
console.log(`Call to doSomething took ${t1 - t0} milliseconds.`);
Copy to Clipboard
Unlike other timing data available to JavaScript (for example Date.now
), the timestamps returned by performance.now()
are not limited to one-millisecond resolution. Instead, they represent times as floating-point numbers with up to microsecond precision.
Also unlike Date.now()
, the values returned by performance.now()
always increase at a constant rate, independent of the system clock (which might be adjusted manually or skewed by software like NTP). Otherwise, performance.timing.navigationStart + performance.now()
will be approximately equal to Date.now()
.
performance.now() => system clock에 의해서 측정되는 timestamp 수치 (microsecond precision).