Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Set Intersection using has and delete vs. Native Set Intersection
(version: 1)
Comparing performance of:
Javascript Set Intersection vs Set Intersection using has and delete
Created:
10 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script>
Script Preparation code:
const first = new Set([...Array(10000)].map(it => String(~~(Math.random() * 10000)))); const second = new Set([...Array(10000)].map(it => String(~~(Math.random() * 200000)))); class MySet extends Set { intersection(other) { other.forEach((element) => { if (this.has(element)) { return; } this.delete(element); }); return this; } } const firstSet = new MySet(first); const secondSet = new MySet(second);
Tests:
Javascript Set Intersection
first.intersection(second)
Set Intersection using has and delete
firstSet.intersection(second)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Javascript Set Intersection
Set Intersection using has and delete
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0
Browser/OS:
Firefox 139 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Javascript Set Intersection
17515.4 Ops/sec
Set Intersection using has and delete
5670.4 Ops/sec
Comments
Confirm delete:
Do you really want to delete benchmark?