Skip to content

Instantly share code, notes, and snippets.

@jasonsturges
Created August 25, 2020 06:56
Show Gist options
  • Save jasonsturges/afe7ea043fe07bc3449f8c4efb114485 to your computer and use it in GitHub Desktop.
Save jasonsturges/afe7ea043fe07bc3449f8c4efb114485 to your computer and use it in GitHub Desktop.
Benchmarking JavaScript - Setting up a timer
let iterations = 100000;
let startTime = new Date().getTime();
for (let i = 0; i < iterations; i++)
Math.log10(0)
let endTime = new Date().getTime();
let time = endTime - startTime;
console.info(`time: ${time}ms, op: ${time / iterations}ms`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment