Created
November 24, 2011 02:45
-
-
Save garindra/1390517 to your computer and use it in GitHub Desktop.
Simple benchmarker function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
benchmark = (name, fn) -> | |
start = new Date().getTime() | |
fn() | |
delta = new Date().getTime() - start | |
console.log 'Benchmark "' + name + '" runs for ' + delta + ' ms.' | |
return delta | |
#example | |
benchmark 'string concat', -> | |
string = "" | |
for i in [0..10000] | |
string += "abcde" | |
#yields : 'Benchmark "string concat" runs for 24ms.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment