Comparativa de rendimiento Map vs. objeto plano

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Objeto plano
// Objeto plano
const obj = {
  foo: 1,
  bar: 2,
  baz: 3
};

let sum = 0;
for (let i = 0; i < 1_000_000; i++) {
  sum += obj.foo + obj.bar + obj.baz;
}
ready
Instancia Map
// Map
const map = new Map([
  ['foo', 1],
  ['bar', 2],
  ['baz', 3]
]);

let sum = 0;
for (let i = 0; i < 1_000_000; i++) {
  sum += map.get('foo') + map.get('bar') + map.get('baz');
}
ready

Revisions

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