Proxy vs native for loop

Benchmark created on


Setup

const obj = { a: 1, b: 2 };
const proxy = new Proxy(obj, {
  get(target, prop) {
    return target[prop];
  },
});

Test runner

Ready to run.

Testing in
TestOps/sec
Native
  for (let i = 0; i < 1e6; i++) {
    let x = obj.a;
  }
ready
Proxied
  for (let i = 0; i < 1e6; i++) {
    let x = proxy.a;
  }
ready

Revisions

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