iterator.find vs for-loop with if (v2)

Revision 2 of this benchmark created on


Setup

const map = new Map();
Array.from({ length: 100_000 }).forEach((_, id) => {
  map.set(id, { id, data: "data-" + id });
});

Test runner

Ready to run.

Testing in
TestOps/sec
iterator.find
map.values().find((x) => x.data === "data-50000");
ready
interator with for and if
for (const value of map.values()) {
  if (value.data === "data-50000") return value;
}
ready

Revisions

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