Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Access to Proxy without Reflect, vs Object
(version: 0)
Comparing performance of:
Object access vs Proxy access vs Proxy with get handler access
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
object = { value: 'data' }; proxy = new Proxy(object, {}) proxyWithHandler = new Proxy(object, { get(target, prop, receiver) { return target[prop] } })
Tests:
Object access
object.value;
Proxy access
proxy.value
Proxy with get handler access
proxyWithHandler.value
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Object access
Proxy access
Proxy with get handler access
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser/OS:
Chrome 138 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Object access
139171440.0 Ops/sec
Proxy access
53096092.0 Ops/sec
Proxy with get handler access
38980052.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks. **Benchmark Definition** The provided JSON represents a benchmark that tests the performance of accessing an object value using different approaches: direct object access, proxy access without reflection, and proxy access with a getter handler. The objective is to measure which approach yields the best performance results. **Options Compared** There are three options being compared: 1. **Direct Object Access**: This approach involves accessing the `value` property of the `object` directly. 2. **Proxy Access without Reflection**: In this case, a proxy object `proxy` is created with an empty handler object `{}` and then accessed like a normal object. 3. **Proxy Access with Get Handler**: A proxy object `proxyWithHandler` is created with a getter handler that returns the value of the corresponding property on the target object. **Pros and Cons** Here's a brief analysis of each approach: * **Direct Object Access**: + Pros: Simple, intuitive, and likely to be optimized by the JavaScript engine. + Cons: May involve more overhead due to type checking and binding. * **Proxy Access without Reflection**: + Pros: May be faster since it avoids type checking and binding overhead. + Cons: The proxy object is created with an empty handler, which means no additional processing is done when accessing its properties. * **Proxy Access with Get Handler**: + Pros: Combines the benefits of both approaches: the getter handler ensures that the correct property is accessed on the target object, while still avoiding type checking and binding overhead. + Cons: Requires creating a custom getter handler, which might add some overhead. **Library Usage** None of the benchmark tests use any external libraries. The code uses native JavaScript features to create proxies and access their properties. **Special JS Features/Syntax** The benchmark tests make use of the following special JavaScript features: * **Proxies**: Used to create proxy objects that can intercept property accesses. * **Getters**: Used in the getter handler to specify how to access properties on the target object. **Other Considerations** When writing this benchmark, consider the following factors that might affect performance: * The size of the object being accessed. * The complexity of the getter handler (if used). * The browser and JavaScript engine being tested. As for alternative approaches or testing scenarios, some possibilities include: * Using different types of objects (e.g., arrays, sets) instead of objects. * Adding more complex getter handlers with nested properties or calculations. * Testing different browsers or versions to see how performance varies across platforms. * Experimenting with different optimization techniques, such as using `Object.create()` or `Proxy` with a more efficient handler. Keep in mind that the specific choices made for this benchmark are likely aimed at isolating the impact of proxy access and getter handlers on performance.
Related benchmarks:
Access to Proxy vs Object with getter
Access to Proxy vs Object - without reflect
Proxy vs Object (without Reflection)
Access to Proxy vs Object vs Getters fixed
Comments
Confirm delete:
Do you really want to delete benchmark?