Object Iteration (v2)

Revision 2 of this benchmark created on


Setup

const object = Object.fromEntries(Array.from({length: 5000}, () => [String(Math.random()), Math.random()]));
const map = new Map(Object.entries(object));

Test runner

Ready to run.

Testing in
TestOps/sec
for entries
let sum = 0;
for (const [key, value] of Object.entries(object)) {
	sum += value;
}
ready
for keys
let sum = 0;
for (const key of Object.keys(object)) {
	sum += object[key];
}
ready
Map Iteration entries
let sum = 0;
for (const [key, value] of map.entries()) {
	sum += value;
}
ready
Map Iteration keys
let sum = 0;
for (const key of map.keys()) {
	sum += object[key];
}
ready

Revisions

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