if-v-for
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var a = [ 1, 2, 3, 4, 5 ],
b = [ 1 ];
function run_if ( a ) {
var l = a.length;
if ( l === 1 ) {
return;
}
for ( var i = 0; i < l; i++ ) {
}
}
function run_for ( a ) {
var l = a.length;
for ( var i = 0; i < l; i++ ) {
}
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
if |
|
pending… |
for |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments