Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
forEach vs for..loop fixed length
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0
Browser:
Firefox 123
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
reduce
121489584.0 Ops/sec
for
369240736.0 Ops/sec
Script Preparation code:
var gsmCells = [ { "countrycode": 250, "operatorid": 2, "lac": 9703, "cellid": 23446, "signal_strength": -75 }, { "countrycode": 250, "operatorid": 2, "lac": 9703, "cellid": 59141, "signal_strength": -76 }, { "countrycode": 250, "operatorid": 2, "lac": 9703, "cellid": 6924, "signal_strength": -80 }, { "countrycode": 250, "operatorid": 2, "lac": 9703, "cellid": 23449, "signal_strength": -81 } ];
Tests:
reduce
let max = gsmCells[0]; gsmCells.forEach( (element, index) => { if(element.signal_strength > max.signal_strength) max = element; } )
for
let max = gsmCells[0]; const a = gsmCells.lenght; for(let i = 0; i < a; i++){ if(gsmCells[i].signal_strength > max.signal_strength) max = gsmCells[i]; }