Skip to content

Instantly share code, notes, and snippets.

@arnorhs
Created August 21, 2011 04:47
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 arnorhs/1160137 to your computer and use it in GitHub Desktop.
Save arnorhs/1160137 to your computer and use it in GitHub Desktop.
js benchmarking
function testcase (func) {
var i, d = new Date();
for (i = 0; i < 10000; i++) {
func();
}
return new Date() - d;
}
time1 = testcase(function () {
// test 1
});
time2 = testcase(function () {
// test 2
});
console.log('time1: '+time1, ', time2: '+time2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment