performance.now vs Date.now in JavaScript

In JavaScript, Date.now() and performance.now() are both used to measure time, but they serve entirely different purposes. While Date.now() returns the current wall-clock time relative to the Unix epoch, performance.now() provides high-resolution, monotonic timestamps measured from the start of the document’s lifecycle. Understanding their differences in precision, time origin, and reliability is essential for choosing the right tool for benchmarking, animations, or logging.

1. Precision and Output Format

2. Time Origin (Baseline)

3. Monotonicity and System Clock Reliance

4. Comparison Summary

Feature Date.now() performance.now()
Resolution Milliseconds (Integer) Microseconds (Floating-point)
Reference Point Unix Epoch (Jan 1, 1970) Page/Process creation time
Clock Type Wall-clock (Non-monotonic) Monotonic clock
Affected by System Time Adjustments Yes No

When to Use Which