Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Proxy target[key] vs Proxy Reflect.get vs object access
(version: 0)
Comparing performance of:
object access vs proxy access vs proxy reflect.get
Created:
one year ago
by:
Registered User
Jump to the latest result
Script Preparation code:
object = { value: 'data' }; proxy = new Proxy(object, { get(target, prop, receiver) { return target[prop] } }) proxyReflect = new Proxy(object, { get(target, prop, receiver) { return Reflect.get(target, prop, receiver) } })
Tests:
object access
object.value
proxy access
proxy.value
proxy reflect.get
proxyReflect.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 reflect.get
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15
Browser/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
object access
390358240.0 Ops/sec
proxy access
88137432.0 Ops/sec
proxy reflect.get
82185544.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and its components. **Benchmark Overview** The provided benchmark compares three different ways to access properties of an object: 1. **Object Access**: Directly accessing the `value` property of the `object`. 2. **Proxy Target Access**: Using a proxy object (`proxy`) that delegates access to the underlying object using the `get()` trap. 3. **Proxy Reflect.get**: Using a proxy object (`proxyReflect`) that uses the `Reflect.get()` function to delegate access to the underlying object. **Options Compared** The benchmark is comparing the performance of these three approaches: * Object Access (direct property access) * Proxy Target Access (using a proxy object with a `get()` trap) * Proxy Reflect.get (using a proxy object with `Reflect.get()`) **Pros and Cons** 1. **Object Access**: * Pros: Simple, efficient, and widely supported. * Cons: May not be optimized for performance, especially when dealing with complex objects or large datasets. 2. **Proxy Target Access**: * Pros: Allows for fine-grained control over access to properties, can be useful in certain scenarios (e.g., data validation). * Cons: Requires creating a proxy object and implementing the `get()` trap, which can add overhead. 3. **Proxy Reflect.get**: * Pros: Uses a standardized function (`Reflect.get()`) for delegation, which is likely to be optimized for performance. * Cons: May not offer as much control over access as using a custom `get()` trap. **Library and Special JS Features** The benchmark uses the following library: * **Proxy**: A built-in JavaScript feature that allows creating proxy objects. There are no special JavaScript features or syntax used in this benchmark, apart from the use of `Reflect.get()`, which is a part of the ECMAScript standard. **Alternatives** Other alternatives to access properties of an object could include: 1. **Property Access using dot notation**: `object.value` 2. **Property Access using bracket notation**: `object['value']` However, these approaches are not directly comparable to the proxy-based methods used in this benchmark. **Benchmark Preparation Code Explanation** The script preparation code creates two objects: `object` and `proxy`, as well as their respective proxies (`proxyReflect`). The `Proxy` constructor is used to create the proxy objects, and the `get()` trap is implemented for each proxy object. The `Reflect.get()` function is also called on the second proxy object (`proxyReflect`).
Related benchmarks:
Access to Proxy vs Object with getter
Access to Proxy vs Object - without reflect
Access to Proxy without Reflect, vs Object
Access to Proxy vs Object vs Getters fixed
Comments
Confirm delete:
Do you really want to delete benchmark?