Skip to content

Instantly share code, notes, and snippets.

@nhunzaker
Created November 13, 2011 13:59
Show Gist options
  • Save nhunzaker/1362133 to your computer and use it in GitHub Desktop.
Save nhunzaker/1362133 to your computer and use it in GitHub Desktop.
Benchmarking JS
// Credit: based on code by John Resig.
var startTime = new Date().getTime();
for (var iters = 0; timeElapsed < 1000; iters++) {
// Run some test code here.
timeElapsed = new Date().getTime() - startTime;
}
// iters = number of iterations achieved in 1000 milliseconds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment