javascript – How to measure js script execution time in microseconds (not milliseconds)


How to detect time in js in microseconds? In particular, I need to summarize the execution time of a piece of code that runs quickly (less than 1 millisecond), but often.


To measure time in microseconds (not milliseconds), you need to use the standard function . It returns a real number (time from the start of the process execution) in milliseconds, and the fractional part is, respectively, microseconds.

var time =;
// некий код
time = - time;
console.log('Время выполнения = ', time);

You can also use console.time('mark') and console.timeEnd('mark') – but here it will not be possible to output to the console and sum up the received time intervals.

Read more here .

Scroll to Top