Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
for loop test brain
(version: 0)
Comparing performance of:
reduce vs for
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = []; for (var i = 0; i < 12345; i++) { arr[i] = i; } function someFn(i) { return (i * 3 * 8 / 1200 * 0.002 / 40 * 0.2); } var sumForEach = 0, sumReduce = 0, sumMap = 0, sumFilter = 0, sumFor = 0;
Tests:
reduce
sumReduce = arr.reduce((lastValue, item) => { return lastValue + someFn(item); }, 0);
for
for (const item of arr) { sumFor += someFn(item); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
reduce
for
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser/OS:
Chrome 130 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
reduce
2023.7 Ops/sec
for
707.0 Ops/sec
Related benchmarks:
forEach vs reduce vs map vs filter vs for vs while
reduce vs for...of
forEach vs reduce vs map vs filter vs for Test
Ocasionalmente vamos falar de um bn name
assphinxtersayswhatsuk
assphinxtersayswhasff
Javascript loop
Comments
Confirm delete:
Do you really want to delete benchmark?