Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Set vs Object delete
(version: 0)
Comparing performance of:
Object vs Set
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var set = new Set(); var object = {}; var array = new Array(5000).fill().map((_, i) => i); for (let i = 0; i < array.length; i++) { object[i] = true; } for (let i = 0; i < array.length; i++) { set.add(i); }
Tests:
Object
delete object[40]
Set
set.delete(40)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Object
Set
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser/OS:
Firefox 146 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Object
54568764.0 Ops/sec
Set
68466400.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and explain what's being tested, compared options, pros and cons of each approach, and other considerations. **Benchmark Overview** The benchmark measures the performance difference between deleting an element from an object versus deleting it from a Set data structure. The test creates an array of 5000 elements and populates an object with a boolean value for each index. Then, it adds all indices to a Set and deletes one specific index (40) using both methods. **Options Compared** There are two options being compared: 1. **Object Delete**: Deleting an element from an object. 2. **Set Delete**: Deleting an element from a Set data structure. **Pros and Cons of Each Approach** ### Object Delete * **Pros**: + Simple and straightforward implementation in most JavaScript engines. + Good cache locality, as the same array is being used for both creation and deletion. * **Cons**: + May involve more overhead due to JavaScript engine's internal data structures (e.g., arrays) and methods (e.g., `delete` on objects). + May lead to slower performance due to potential side effects of deleting an element from a larger object. ### Set Delete * **Pros**: + Optimized for Set operations, with faster execution times in most JavaScript engines. + Less overhead compared to Object delete, as Sets are designed for fast lookups and removals. * **Cons**: + Requires the creation of an additional data structure (the Set) before deletion. + May not utilize cache locality as effectively, leading to slower performance due to array access patterns. **Other Considerations** The benchmark also considers the following: * JavaScript version: The benchmark is likely designed for a specific version of JavaScript or a range of versions that includes modern standards like ES6 and later. * Browser and Device: The benchmark runs on Firefox Mobile 130, Android 14, with an ARM-based CPU. This limits the scope to mobile devices running this particular browser and operating system. **Additional Insights** The use of `fill()` and `map()` functions in the script preparation code allows for a more efficient creation of the array and object, as well as populating the object with boolean values. The Set data structure is created using the `Set` constructor, which is optimized for fast lookups and removals. In terms of special JS features or syntax, there are no notable mentions in the provided benchmark code or JSON definitions.
Related benchmarks:
Set array expansion Part 2
creating maps vs creating objects
Set vs Object add
allocating objects vs allocating maps
Comments
Confirm delete:
Do you really want to delete benchmark?