Object frozen vs unfrozen

Benchmark created on


Setup

const unfrozenMapping = {
  foo: 1,
  bar: 2,
  baz: 3,
}

const frozenMapping = Object.freeze({
  foo: 1,
  bar: 2,
  baz: 3,
});

const unfrozenData = {
  foo: 'hello',
  bar: 'world',
  baz: 123,
}

const frozenData = Object.freeze({
  foo: 'hello',
  bar: 'world',
  baz: 123,
});

Test runner

Ready to run.

Testing in
TestOps/sec
Frozen data, unfrozen mapping

    for (const key in frozenData) {
      const x = unfrozenMapping[key];
    }
ready
Unfrozen data, unfrozen mapping

    for (const key in unfrozenData) {
      const x = unfrozenMapping[key];
    }
ready
Frozen data, frozen mapping

    for (const key in frozenData) {
      const x = frozenMapping[key];
    }
ready
Unfrozen data, frozen mapping

    for (const key in unfrozenData) {
      const x = frozenMapping[key];
    }
ready

Revisions

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