“JavaScript Measure Function Time” Kode Jawaban

JavaScript Measure Function Time

var startTime = performance.now();

alert('Run some function here');

var endTime = performance.now();
var totalTime=endTime-startTime;// time took to run in milliseconds

alert('Total time:'+totalTime +'ms');
Grepper

JavaScript Measure Function 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;
MattDESTROYER

Jawaban yang mirip dengan “JavaScript Measure Function Time”

Pertanyaan yang mirip dengan “JavaScript Measure Function Time”

Lebih banyak jawaban terkait untuk “JavaScript Measure Function Time” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya