Skip to main content
One method:

performance.now()

It reads the monotonic clock (.awake — CLOCK_MONOTONIC / UPTIME_RAW), latches the origin on first use, and divides nanoseconds by 1e6. Only performance.now exists — there are no mark, measure, timeOrigin, or navigation members.

Timing patterns

Measure a block

Time a request end to end

Benchmark loop

vs console.time

Use performance.now() for measurements; use console.time for human-visible timings in logs.

Gotchas

  • The origin is the first call, not process start — anything before your first performance.now() is invisible. Call it once at boot if you need a stable baseline.
  • It’s a float: compare and print with rounding (toFixed) to avoid 0.041000000000000002 noise.
  • Sub-millisecond values are real but coarse — single samples are noise; average over iterations.
  • In Workers each runtime has its own origin.

See also