Array VS Iterrator (v4)

Revision 4 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(DROP_NO, DROP_NO + TAKE_NO).filter(el => el < 7000).map(el => el + 5)
ready
Iterrator
const iter_res = arr.values().drop(DROP_NO).take(TAKE_NO).filter(el => el < 7000).map(el => el + 5)
ready

Revisions

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