Array map vs for loop
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var to_iterate = new Array(100);
for (var i = 0; i < 100; i++) {
to_iterate[i] = i;
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
For loop |
|
pending… |
Map with predefined function |
|
pending… |
Map with inline function |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments