Skip to content

Instantly share code, notes, and snippets.

@arthurschreiber
Created March 11, 2010 09:27
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 arthurschreiber/328990 to your computer and use it in GitHub Desktop.
Save arthurschreiber/328990 to your computer and use it in GitHub Desktop.
<!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>
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