In brief
performance.now() returns a time value in milliseconds relative to the environment’s time origin.
Useful to know
performance.now() returns a time value in milliseconds relative to the environment’s time origin. It is intended for measuring intervals rather than displaying calendar dates. [1]
Record const start = performance.now();, perform the operation, then calculate const elapsed = performance.now() - start;. The result is the interval in milliseconds. There is no fixed result for this demonstration because it depends on the actual execution.
For asynchronous work, decide whether the measurement covers only starting the operation or waiting for it to finish. Measuring immediately after starting a request does not cover its complete lifetime.
One attempt cannot establish that an algorithm is universally faster. Data, device, load and runtime warm-up affect the result. Distinguish a demonstration of the measuring method from a real comparison.
Sources
For further detail and to check the information: