Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set Intersection using has and delete vs. Native Set Intersection
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0
Browser:
Firefox 139
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
Javascript Set Intersection
17515.4 Ops/sec
Set Intersection using has and delete
5670.4 Ops/sec
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)