Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Proxy JS Set Benchmark
(version: 1)
Comparing performance of:
object.value =1; vs proxy.value =1; vs proxyWithSet.value =1;
Created:
2 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
object = { value: 'data' }; proxy = new Proxy(object, {}) proxyWithSet = new Proxy(object, { set(target, prop, value) { target[prop] = value; return value; } })
Tests:
object.value =1;
object.value =1;
proxy.value =1;
proxy.value =1;
proxyWithSet.value =1;
proxyWithSet.value =1;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
object.value =1;
proxy.value =1;
proxyWithSet.value =1;
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser/OS:
Chrome 129 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
object.value =1;
7216072.5 Ops/sec
proxy.value =1;
2347082.8 Ops/sec
proxyWithSet.value =1;
5614600.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**What is being tested?** The provided benchmark tests the performance of three different approaches for setting values in a JavaScript object: 1. **Direct assignment**: `object.value = 1;` 2. **Proxy with a setter function**: `proxy.value = 1;` 3. **Proxy with a setter function using a set() method**: `proxyWithSet.value = 1;` These tests aim to measure the performance differences between these approaches. **Options comparison** The three options are compared in terms of their execution speed and efficiency. * **Pros and cons:** + **Direct assignment (`object.value = 1;`)**: - Pros: Simple, straightforward, and efficient. - Cons: May not provide optimal performance due to potential caching or optimization by the JavaScript engine. + **Proxy with a setter function (`proxy.value = 1;`)**: - Pros: Provides more flexibility and control over the setting process. - Cons: May introduce additional overhead due to the creation of a proxy object, which can lead to slower performance compared to direct assignment. + **Proxy with a setter function using a set() method (`proxyWithSet.value = 1;`)**: - Pros: Provides more control and flexibility over the setting process, similar to the previous option. - Cons: May introduce additional overhead due to the creation of a proxy object and the use of the `set()` method, which can lead to slower performance compared to direct assignment. **Library usage** In this benchmark, the `Proxy` class is used to create proxy objects. The `Proxy` class is a built-in JavaScript class that allows you to create a proxy object, which can be used to control access to an object's properties or methods. The `set()` method is also used in two of the test cases (`proxy.value = 1;` and `proxyWithSet.value = 1;`) to set values on the proxy objects. The `set()` method is a built-in JavaScript method that can be used to add new properties to an object or update existing ones. **Special JS features or syntax** There are no special JS features or syntax used in this benchmark. **Other alternatives** If you want to create similar benchmarks, you could consider testing other approaches for setting values in a JavaScript object, such as: * Using a library like `lodash` or `ramda` that provides functional programming utilities. * Testing the performance of different data structures, such as arrays or objects. * Creating benchmarks with custom JavaScript functions or methods. Some popular alternatives to MeasureThat.net include: * **Benchmark.js**: A high-performance benchmarking framework for Node.js. * **JSMeter**: A JavaScript benchmarking library that allows you to create and run benchmarks. * **jsbench**: A lightweight JavaScript benchmarking tool that supports multiple test cases.
Related benchmarks:
ES6 Proxy vs JS Object get/set
ES6 Proxy vs JS Object get/set vs get/set Function
Access to Proxy vs Object Another one, nother one
Plain object access vs Proxy vs Property
Comments
Confirm delete:
Do you really want to delete benchmark?