Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
frozen VS unfrozen object iteration times
(version: 0)
Comparing performance of:
unfrozen iteration vs frozen iteration
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var o1 = {a: 1}; var o2 = {a: 1}; Object.freeze(o2);
Tests:
unfrozen iteration
for(var key in o1);
frozen iteration
for(var key in o2);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
unfrozen iteration
frozen iteration
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.2 Safari/605.1.15
Browser/OS:
Safari 26 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
unfrozen iteration
98646272.0 Ops/sec
frozen iteration
9072917.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and explain what's being tested, compared, and its pros and cons. **What is being tested?** The benchmark compares the iteration times of two objects: `o1` (unfrozen) and `o2` (frozen). The test checks how fast each object can be iterated over using a simple `for...in` loop. **Options compared:** There are two options being compared: 1. **Unfrozen object iteration**: This option uses the original, unfrozen `o1` object. 2. **Frozen object iteration**: This option uses the frozen `o2` object. **Pros and Cons of each approach:** * **Unfrozen object iteration**: + Pros: Faster iteration times since the object is not frozen, allowing for more efficient internal workings. + Cons: May be slower due to additional checks or overhead when iterating over an unfrozen object. * **Frozen object iteration**: + Pros: More predictable and consistent behavior, as the object's internal state is stabilized. + Cons: Slower iteration times since the frozen object has additional overhead for stabilization. **Library used (if any):** None of the test cases use any external libraries. The benchmark only relies on standard JavaScript features and built-in objects like `Object.freeze()`. **Special JS feature or syntax:** The test case uses the `Object.freeze()` method to freeze the `o2` object, which is a JavaScript-specific feature for stabilizing an object's internal state. **Other alternatives:** In theory, other approaches could be used to iterate over objects, such as: * Using `for...of` loops instead of `for...in` loops. * Utilizing libraries like Lodash or Ramda that provide optimized iteration functions. * Implementing custom iteration logic using recursive functions or other techniques. However, the standard `for...in` loop is a common and widely supported approach in JavaScript, making it a suitable choice for this benchmark. Now you know what's being tested and compared in this benchmark!
Related benchmarks:
Testing JS Performance of deleting a large map.
Object property: delete vs undefined 2
Delete vs destructure vs reduce for objects
Map() delete while iterating vs clear
Empty an object in JavaScript (with baseline)
Comments
Confirm delete:
Do you really want to delete benchmark?