How can you use a JavaScript time function to measure how long a function takes to execute in milliseconds?

I’ve been working with performance tuning in JS for over a decade now…”* If you’re measuring how long a function takes, performance.now() is still the most accurate JavaScript time function for browser environments. It offers sub-millisecond precision, unlike Date.now() or new Date().getTime() which are only accurate to the millisecond. Here’s a quick snippet:

const start = performance.now();
someFunction();
const end = performance.now();
console.log(`Execution time: ${(end - start).toFixed(3)}ms`);

Still rock-solid in 2025. Unless you’re digging into deeper performance profiling or working in Node.js, this does the job beautifully.