Iterating Proxies

JavaScript performance comparison

Test case created by BDawgonnit

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const toFrozenCopy = o =>
    Object.freeze(Object.assign({}, o))
  
  const toProxy = o =>
    new Proxy(o, {
      set(obj, prop, value) {
        obj[prop] = value
      },
    })
  
  const length = 25
  const objects = new Array(length)
  for (let i=0; i<length; i++) {
    objects[i] = { x: i, y: i-1, z: `${i}` }
  }
  
  const frozenObjects = objects.map(toFrozenCopy)
  const proxiedObjects = objects.map(toProxy)

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Iterate Objects
objects.forEach(o => o.i)
pending…
Iterate Proxied Objects
proxiedObjects.forEach(o => o.i)
pending…
Iterate Frozen Copies
frozenObjects.forEach(o => o.i)
pending…

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

Compare results of other browsers

0 Comments