Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
reduce or forEach
(version: 1)
Comparing performance of:
Reduce vs For Each
Created:
15 days ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var a = Array.from({length:100},()=>Math.random()< 0.5 ? { igvTax: 0, subtotal: 100*Math.random()}: { igvTax: 1, subtotal: 100*Math.random()}); var b = 0;
Tests:
Reduce
b = a.reduce((acc, { subtotal, igvTax })=>{ if(!igvTax) return acc return acc += subtotal },0)
For Each
a.forEach(({ subtotal, igvTax }) => { if(!igvTax) return b += subtotal })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Reduce
For Each
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
15 days ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36
Browser/OS:
Chrome 147 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Reduce
8866247.0 Ops/sec
For Each
259364.9 Ops/sec
Related benchmarks:
reduce vs loop
map vs forEach vs for loop
filter by indices
reduce vs for...of
Array.reduce
Array ForEach vs Find vs for loop
Array ForEach vs Find vs for loop (2)
Javascript loop
Array looping - for, Array.forEach, for-of, array.entries()
Comments
Confirm delete:
Do you really want to delete benchmark?