performance.now vs Date.now Playground

The neighbourhood head’s stopwatch is performance.now() and the tent’s wall clock is Date.now(): every heat is timed by both for real, the stopwatch’s…

Why it matters

Timing a duration with Date.now() can go wrong: too coarse for small work, and negative when the system clock is set. Keeping performance.now() as a time is wrong too: its number only means something on that page.

The key idea

The stopwatch for durations, the wall clock for times

Common mistakes

Try it in this playground