How to measure the performance of a function in JavaScript
Here are 2 ways to measure the performance of a function in javascript:
console.time('function');
function();
console.timeEnd('function');
or:
const startTime = performance.now();
function();
const endTime = performance.now();
console.log(`Function took ${endTime - startTime} milliseconds`);