Array VS Iterrator (v5)

Revision 5 of this benchmark created on


Setup

function generateData(size) {
    return Array.from({ length: size }, (_, i) => i);
}

const arr = generateData(100000);
const TAKE_NO = Math.floor(Math.random() * 5000);
const DROP_NO = Math.floor(Math.random() * 1000);

Teardown

// console.log(arr_res.length == iter_res.length ? 'CORRECT' : 'UNEQUAL DATA PASSED')

Test runner

Ready to run.

Testing in
TestOps/sec
Array
const arr_res = arr.slice(1).map(el => el /2).slice(1).map(el => el + 5).slice(1).map(el => el +5).slice(1).map(el => el -3).slice(0,10)
ready
Iterrator
const iter_res = arr.values().drop(1).map(el => el /2).drop(1).map(el => el + 5).drop(1).map(el => el +5).drop(1).map(el => el -3).take(10).toArray()
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.