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; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
array methods
20869.6 Ops/sec
iterators
242949.4 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); }