Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Test map reduce vs for...loop
(version: 0)
Comparing performance of:
Slice and reduce vs For loop
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; var ndata = data.reduce((acc, value, index) => { acc[index] = (acc[index - 1] || 0) + value; return acc; }, []);
Tests:
Slice and reduce
var copy = [...ndata.slice(0, 2), ...data.slice(3,9).reduce((acc, value, index) => { acc[index] = (acc[index - 1] || 0) + value; return acc; }, []) ];
For loop
var copy = [...ndata.slice(0, 2)]; for (var i = 3; i < 8; i++) { copy[i] = (ndata[i] || 0) + 34; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Slice and reduce
For loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Browser/OS:
Chrome 128 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Slice and reduce
1771042.2 Ops/sec
For loop
1582999.5 Ops/sec
Related benchmarks:
map vs for...of vs for
flatMap vs reduce test
flatMap vs reduce test 2
flatMap vs reduce test 3
Comments
Confirm delete:
Do you really want to delete benchmark?