Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Access from Object.seal vs Object.freeze vs normal
(version: 0)
Comparing performance of:
seal vs normal vs freeze
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var a = Object.seal( {x: 321, y: 123} ); var b = {x: 321, y: 123} var c = Object.freeze( {x: 321, y: 123} );
Tests:
seal
a.x; a.y;
normal
b.x; b.y;
freeze
c.x; c.y;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
seal
normal
freeze
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 months ago
)
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1
Browser/OS:
Mobile Safari 18 on iOS 18.5
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
seal
208465792.0 Ops/sec
normal
173356864.0 Ops/sec
freeze
223946576.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the provided benchmark definition and explain what's being tested, compared, pros and cons of each approach, and other considerations. **Benchmark Definition** The provided benchmark definition is a JSON object that defines a set of microbenchmarks to be executed by MeasureThat.net. The benchmark has three test cases: 1. `seal`: Measures the performance of accessing properties on an object that has been sealed using `Object.seal()`. 2. `normal`: Measures the performance of accessing properties on an object without any sealing or freezing. 3. `freeze`: Measures the performance of accessing properties on an object that has been frozen using `Object.freeze()`. **Script Preparation Code** The script preparation code is a JavaScript snippet that sets up the test objects: ```javascript var a = Object.seal( {x: 321, y: 123} ); var b = {x: 321, y: 123}; var c = Object.freeze( {x: 321, y: 123} ); ``` This code creates three objects: * `a` is sealed using `Object.seal()`. * `b` is a regular object without any sealing or freezing. * `c` is frozen using `Object.freeze()`. **Html Preparation Code** There is no HTML preparation code provided, so it's likely that the benchmark doesn't rely on any specific HTML elements or interactions. **Library and Purpose** None of the test cases use any external libraries. The only JavaScript features being tested are: * `Object.seal()`: Seals an object, making certain properties immutable. * `Object.freeze()`: Freezes an object, making it immutable. The purpose of these functions is to provide a way to create objects with specific accessibility controls, allowing developers to test the performance implications of accessing properties on sealed or frozen objects. **Pros and Cons** Here's a brief summary of the pros and cons of each approach: * `Object.seal()`: + Pros: Provides a way to control access to certain properties without modifying the object itself. + Cons: Can lead to unexpected behavior if not used carefully, as sealed properties can still be accessed using bracket notation (`obj[x]`). * `Object.freeze()`: + Pros: Provides a more comprehensive way to make an object immutable by preventing any modifications to its properties or children. + Cons: Can have performance implications due to the added overhead of freezing the object. **Other Considerations** When testing these benchmarks, it's essential to consider the following: * The use cases where `Object.seal()` and `Object.freeze()` might be relevant, such as in situations where data integrity is critical or when working with legacy code. * The potential performance implications of using these functions, particularly for large datasets or high-traffic applications. * The fact that sealed properties can still be accessed using bracket notation (`obj[x]`), which might affect the results of this benchmark. **Alternatives** Other alternatives to `Object.seal()` and `Object.freeze()` include: * Using property descriptors: Instead of sealing or freezing an object, you can use property descriptors to control access to specific properties. * Using classes or constructors: You can define classes or constructors that provide a way to create objects with specific accessibility controls. However, these alternatives might not be suitable for all use cases and may require additional considerations.
Related benchmarks:
Destructure from Object.seal vs Object.freeze vs normal
Destructure from Object.seal vs Object.freeze vs normal(special edition)
Object.freeze vs Object.seal vs Native
normal vs Object.freeze vs Object.seal performance
Comments
Confirm delete:
Do you really want to delete benchmark?