Object vs Proxy vs Proxy setter
Date tested:
one year ago
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.0.0
Test name
Executions per second
Object
5720529.0 Ops/sec
Proxy
1571377.0 Ops/sec
Proxy setter
1233185.0 Ops/sec
Benchmark definition (click to collapse):
Script Preparation code:
object = { test: 1 } proxy = new Proxy(object, {}) proxyWithHandler = new Proxy(object, { set(target, prop, value) { target[prop] = value } })
Tests:
Object
object.test = 1
Proxy
proxy.test = 1
Proxy setter
proxyWithHandler.test = 1
Open this result on MeasureThat.net