Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Generator function vs array loop vs map
(version: 1)
Comparing performance of:
generator vs map vs loop
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
generator
const array = [...Array(10000).keys()]; function* generator(iterator) { for (const el of iterator) { yield el + 1; } } [...generator(generator(generator(array)))].length;
map
const array = [...Array(10000).keys()]; function map(iterator) { return iterator.map(el => el + 1); } [...map(map(map(array)))].length;
loop
const array = [...Array(10000).keys()]; function loop(iterator) { const clone = []; for (let a = 0; a < iterator.length; a++) { clone.push(iterator[a] + 1); } return clone; } [...loop(loop(loop(array)))].length;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
generator
map
loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser/OS:
Firefox 146 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
generator
442.0 Ops/sec
map
3072.1 Ops/sec
loop
4606.4 Ops/sec
Comments
Confirm delete:
Do you really want to delete benchmark?