Skip to content

Instantly share code, notes, and snippets.

@DaveGoosem
Created November 12, 2013 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaveGoosem/7432179 to your computer and use it in GitHub Desktop.
Save DaveGoosem/7432179 to your computer and use it in GitHub Desktop.
Simple Javascript Performance Testing. Write the same code using different methods and then use this to test execution time (can output it to console). Dev tools may / may not give you same results.
/*
* We need to run the code sample more than once to get a better idea of running time during analysis.
* set this value to be however many times you want to run the code to get a good analysis
* of running time
*/
var maxCount = 20;
var start = new Date().getTime();
for (var n = 0; n < maxCount; n++) {
/* perform operation you want to measure */
}
var elapsed = new Date().getTime() - start;
console.log("code snippet ran in: " + elapsed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment