Test Array loop with sort method
JavaScript performance comparison
Preparation code
<script>
var myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35];
var res = 0;
function each(a,f){
var l=a.length,
i=l;
l++;
while (--l) {
var b = i-l;
f(a[b],b);
}
}
function each2(a,f){
for(var i=0,l=a.length;i!==l;i++){
f(a[i],i);
}
}
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Array each |
|
pending… |
Array each2 |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments