Access to Proxy vs Array
Date tested:
one month ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Test name
Executions per second
Array access
142150224.0 Ops/sec
Proxy access
21883988.0 Ops/sec
Proxy with reflect handler
11343484.0 Ops/sec
Proxy with handler
14762487.0 Ops/sec
Benchmark definition (click to collapse):
Script Preparation code:
object = ['data']; proxy = new Proxy(object, {}) proxyWithHandler = new Proxy(object, { get(target, prop, receiver) { return Reflect.get(target, prop, receiver) } }) proxyWithHandler2 = new Proxy(object, { get(target, prop, receiver) { return target[prop] } })
Tests:
Array access
object[0];
Proxy access
proxy[0]
Proxy with reflect handler
proxyWithHandler[0]
Proxy with handler
proxyWithHandler2[0]
Open this result on MeasureThat.net