Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array vs Iterators
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0
Browser:
Firefox 113
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
array methods
13217.8 Ops/sec
iterators
394601.5 Ops/sec
Script Preparation code:
var numbers = Array.from({length: 5}, (v, i) => i)
Tests:
array methods
numbers .map(x => x+1) .map(x => x*2) .map(x => x-1) .map(x => x/2) .forEach(console.log)
iterators
function * map(mapperFn, iterable) { for (const item of iterable) { yield mapperFn(item); } } numbers = map(x => x+1, numbers); numbers = map(x => x*2, numbers); numbers = map(x => x-1, numbers); numbers = map(x => x/2, numbers); for (const item of numbers) { console.log(item); }