var t0 = performance.now();
doSomething(); // <---- The function you're measuring time for
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
console.time("My Descriptive Title");
doSomething(); // <--- the function that you want to time
console.timeEnd("My Descriptive Title"); // Argument has to match
// My Descriptive Title: 8917.283ms
const { JSDOM } = require("jsdom");
const { window } = new JSDOM();
var start = window.performance.now();
// task starts
for (var i = 0; i < 100000000;i++);
// task ends
var end = window.performance.now();
console.log(`Execution time: ${end - start} ms`);
var t0 = performance.now();
doSomething(); // <---- The function you're measuring time for
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
program execution time in javascript
console.time("My Descriptive Title");
doSomething(); // <--- the function that you want to time
console.timeEnd("My Descriptive Title"); // Argument has to match
// My Descriptive Title: 8917.283ms
const { JSDOM } = require("jsdom");
const { window } = new JSDOM();
var start = window.performance.now();
// task starts
for (var i = 0; i < 100000000;i++);
// task ends
var end = window.performance.now();
console.log(`Execution time: ${end - start} ms`);
program execution time in javascript