Map iteration

Benchmark created by Will Nelson on


Preparation HTML

<script src="//wzrd.in/standalone/uuid@latest"></script>

Setup

const map = new Map();
  
  for(let i = 0; i < 10000; i++) map.set(uuid.v4(), i);

Test runner

Ready to run.

Testing in
TestOps/sec
for...of
for(const e of map) e[1];
ready
for...of (destructured)
for(const [k, v] of map) v;
ready
for...of Map#keys
for(const k of map.keys()) map.get(k);
ready
Map#entries
for(const v of map.entries()) v;
ready
Map#forEach
map.forEach(v => v);
ready
Array.from (for...of)
for(const v of Array.from(map)) v;
ready
array from Map#keys
Array.from(map.keys()).forEach(k => map.get(k));
ready
Array.from Map#entries
Array.from(map.entries()).forEach(v => v);
ready

Revisions

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

  • Revision 1: published by Will Nelson on