array vs map (v2)

Revision 2 of this benchmark created on


Setup

const array = new Array(1000).fill(Math.random);

const map = new Map();
array.forEach((n) => {
  map.set(n, 1);
});

Test runner

Ready to run.

Testing in
TestOps/sec
map
const mapLength = map.size;
let n = 0;
for (var i = 0; i < mapLength; i++) {
  n += i;
}
ready
array
const arrayLength = array.length;
let n = 0;
for (var i = 0; i < arrayLength; i++) {
  n += i;
}
ready

Revisions

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