Created
March 11, 2010 09:27
-
-
Save arthurschreiber/328990 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Benchmark for Array#_each</title> | |
<script type="text/javascript" src="../../dist/prototype.js"></script> | |
<script type="text/javascript"> | |
var Benchmark = { | |
results: [], | |
iterations: 1000, | |
run: function(name, fn) { | |
var i = 0, start = (new Date).getTime(); | |
for(; i<this.iterations; ++i) { | |
fn(); | |
} | |
var end = (new Date).getTime(); | |
this.results.push([name, end - start]) | |
} | |
}; | |
var array = $R(1, 1000).toArray(); | |
Benchmark.run("#each", function() { | |
array.each(Prototype.K); | |
}); | |
alert(Benchmark.results.inspect()); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
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
Results: Opera 10.50 Firefox 3.6 Firefox 3.7 Chrome 5.0.342.2 IE 8.0 | |
Default #each 431ms 733ms 727ms 149ms 1640ms | |
Patched #each 113ms 119ms 130ms 33ms 893ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment