Posted By

cerxx on 04/15/19


Tagged

js-hacks


Versions (?)

How to measure the js script lead time


 / Published in: JavaScript
 

URL: https://ru.stackoverflow.com/questions/520048/%D0%9A%D0%B0%D0%BA-%D0%B8%D0%B7%D0%BC%D0%B5%D1%80%D0%B8%D1%82%D1%8C-%D0%B2%D1%80%D0%B5%D0%BC%D1%8F-%D0%B2%D1%8B%D0%BF%D0%BE%D0%BB%D0%BD%D0%B5%D0%BD%D0%B8%D1%8F-js-%D1%81%D0%BA%D1%80%D0%B8%D0%BF%D1%82%D0%B0-%D0

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

  1. var time = performance.now();
  2. // some code
  3. time = performance.now() - time;
  4. console.log('????? ?????????? = ', time);

Report this snippet  

You need to login to post a comment.