JavaScript · Senior · Question 28 of 75

Why is performance.now() better than Date.now() for measuring execution time?

Explanation

Date.now() is milliseconds by the system clock, which can shift (sync, time changes). performance.now() counts from the start of navigation with fractional milliseconds. For marks in DevTools there are performance.mark() and measure().

Further reading

Problem with a question

JavaScript · Senior · question 28

Test yourself

Take the JavaScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz