Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Javascript measure function run time

/* record the current time (the current time
being the time since the current tab was
loaded in milliseconds) */
const start = performance.now();

// run your function here

/* record the current time after your
function has run */
const end = performance.now();

/* to get the time ellapsed, you simply
subtract the start time from the end time */
const ellapsed = end - start;

/* you could convert this into seconds by
dividing by 1000 */
const secondsEllapsed = ellapsed / 1000;
 
PREVIOUS NEXT
Tagged: #Javascript #measure #function #run #time
ADD COMMENT
Topic
Name
2+9 =