Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object.freeze vs Object.seal call
(version: 0)
Comparing performance of:
normal vs freeze vs seal
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var obj = { "vbmujvv": "rfigcpcvpj", "sjmcgvvk": 3, "efdarehl": { "odinthsuca": "rwjhmbfus", "noihjtjen": 27.73332043042913, "brspkaagb": "lnuiabcfd" }, "febtungjhfokf": 49.28625818957401, "eoemrkgi": { "jkcuwrpsh": "ekjoltm", "cincs": { "fcovbwk": { "whsgmjh": 48.00843935524626, "agsjflef": 46.700796253998014 }, "ovkdfudgfm": 84.83383163217746, "fpfetl": "djuvfjbjptf", "kobmkstj": { "wskgkkerk": 9, "kvnptptek": 37.63655947554132, "dsloun": 4 } }, "krirwk": { "sjgftomu": 51.663884142674775, "hpjgibnli": 4 }, "pkhkgruls": "isuodwjrg" }, "ortomnue": 71.71303423929236 };
Tests:
normal
const t = obj;
freeze
const t = Object.freeze(obj);
seal
const t = Object.seal(obj);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
normal
freeze
seal
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/126.0.0.0 Safari/537.36
Browser/OS:
Chrome 126 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
normal
30459264.0 Ops/sec
freeze
9908244.0 Ops/sec
seal
10042837.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll provide an explanation of the provided benchmark. **Benchmark Description** The benchmark compares the performance differences between `Object.freeze()` and `Object.seal()` when freezing an object in JavaScript. The test case uses a complex object with nested properties to measure the overhead of freezing an object using these two methods. **Options Compared** * `Object.freeze()`: This method creates a new, immutable copy of the object, which cannot be modified or deleted. * `Object.seal()`: This method creates a new object that inherits from the original object and prevents the modification of certain properties. However, some properties may still be modifiable. **Pros and Cons** * **`Object.freeze()`**: Pros: + Provides strong immutability guarantees, making it suitable for situations where data integrity is critical. + Can prevent malicious modifications to the object. * Cons: + Creates a new object, which can incur additional memory overhead. + May be slower than `Object.seal()` due to the creation of a new object. * **`Object.seal()```**: Pros: + Does not create a new object, reducing memory overhead compared to `Object.freeze()`. + Can still provide some level of protection against malicious modifications. * Cons: + May not be suitable for situations where immutability is crucial. + Some properties may still be modifiable. **Library and Purpose** None of the libraries are explicitly mentioned in this benchmark. However, JavaScript objects are a built-in part of the language, and `Object.freeze()` and `Object.seal()` are standard methods provided by the JavaScript specification. **Special JS Features or Syntax** There is no specific JavaScript feature or syntax being tested in this benchmark. The focus is on comparing the performance differences between two existing methods (`Object.freeze()` and `Object.seal()`) that are part of the language's standard library. **Other Alternatives** If you need to freeze an object, other alternatives might include: * Using a third-party library like Lodash or Immutable.js, which provide similar functionality. * Implementing your own custom freezing mechanism using JavaScript's prototype chain and property accessors. * Using a different data structure altogether, such as a JSON-like object with explicit accessors. In general, the choice of method depends on the specific requirements of your project, including performance considerations, memory constraints, and the level of immutability needed.
Related benchmarks:
Destructure from Object.seal vs Object.freeze vs normal
Object.freeze vs Object.seal vs Native
Access from Object.seal vs Object.freeze vs normal
normal vs Object.freeze vs Object.seal performance
Freeze vs no freeze
Comments
Confirm delete:
Do you really want to delete benchmark?