function mul(a, n) {
let total = 0;
for (let i = 0; i < n; i++)
total += a;
return total;
}
// performance.now() method returns a high-resolution timestamp in milliseconds
const start = performance.now();
mul(10, 3000);
const end = performance.now();
console.log('Function execute time: ' + (end - start) + ' milliseconds');
/*
run:
Function execute time: 0.12034999951720238 milliseconds
*/