Object Iteration (v5)

Revision 5 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
for entries
const object = Object.fromEntries(Array.from({length: 5000}, () => [String(Math.random()), Math.random()]));
let sum = 0;
for (const [key, value] of Object.entries(object)) {
	sum += value;
}
ready
for keys
const object = Object.fromEntries(Array.from({length: 5000}, () => [String(Math.random()), Math.random()]));
let sum = 0;
for (const key of Object.keys(object)) {
	sum += object[key];
}
ready
Map Iteration entries
const entries = Array.from({length: 5000}, () => [String(Math.random()), Math.random()]);
const map = new Map(entries);
let sum = 0;
for (const [key, value] of map.entries()) {
	sum += value;
}
ready
Map Iteration keys
const entries = Array.from({length: 5000}, () => [String(Math.random()), Math.random()]);
const map = new Map(entries);
let sum = 0;
for (const key of map.keys()) {
	sum += map.get(key);
}
ready
for entries (no destructuring)
const object = Object.fromEntries(Array.from({length: 5000}, () => [String(Math.random()), Math.random()]));
let sum = 0;
for (const entry of Object.entries(object)) {
	sum += entry[1];
}
ready

Revisions

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