How the Stopwatch Measures Time Accurately
AnyTool Stopwatch is timestamp-based and counts up. When you press Start it records the current epoch milliseconds; on every animation frame it computes elapsed time as the time already accumulated from earlier runs plus Date.now() minus that start moment, rather than adding a fixed step to a counter each frame. A requestAnimationFrame loop drives a smooth centisecond display while running and is cancelled on Stop and on unmount. Because the value is derived from the wall clock, the total elapsed time stays correct even when a background tab throttles its frames — the live animation simply pauses while the tab is hidden and the figure self-corrects the instant it is visible again. Stop captures the accumulated time so Resume continues exactly, and Reset clears the elapsed time and all laps.
- Counts up; elapsed = accumulated + (Date.now() − start) each frame
- requestAnimationFrame drives a smooth live centisecond display
- Foreground accuracy around 10 ms; total self-corrects after throttling
- Stop accumulates time so Resume continues seamlessly
- RAF is cancelled on pause and on unmount — no leaked loops
