Object vs Proxy vs Proxy setter

2 years 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 5720528.5 Ops/sec
Proxy 1571376.6 Ops/sec
Proxy setter 1233185.2 Ops/sec
Script Preparation code:
x
 
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