Loop perf

JavaScript performance comparison

Test case created by rjf

Preparation code

<script>
d=[];
for(i=0; i<1000; i++) d.push({'sequenceNo':Math.random()});
</script>
    

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Apply
console.log(Math.min.apply(Math, d.map(i => i.sequenceNo)))
pending…
Reduce
console.log(d.map(i => i.sequenceNo).reduce((a,b) => Math.min(a,b)));
pending…
For-of Loop
var m; for ({sequenceNo} of d) m = sequenceNo > m ? m : sequenceNo 
console.log(m)
pending…
Ternary
console.log(d.map(i => i.sequenceNo).reduce((a,b) => a < b ? a : b));
pending…
Loop Tern
var m=d[0];for (var i=1;i<d.length;i++) m = m < d[i].sequenceNo ? m : d[i].sequenceNo
console.log(m);
pending…
Loop Min
var m=d[0];for (var i=1;i<d.length;i++) m = Math.min(d[i].sequenceNo,m)
console.log(m)
pending…
Reduce Single
console.log(d.reduce((min, el) => min.sequenceNo < el.sequenceNo ? min : el).sequenceNo)
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments