Compare perf of allocating and comparing sets, vs. arrays
const arrA = [1, 2, 3]
const arrB = [2, 3, 4]
const arr1000A = Array.from({ length: 1000 }).map((_, i) => i)
const arr1000B = [...arr1000A.slice(1), 1000]
const arr10000A = Array.from({ length: 10000 }).map((_, i) => i)
const arr10000B = [...arr10000A.slice(1), 10000]
const arr100000A = Array.from({ length: 100000 }).map((_, i) => i)
const arr100000B = [...arr100000A.slice(1), 100000]
const arr1000000A = Array.from({ length: 1000000 }).map((_, i) => i)
const arr1000000B = [...arr1000000A.slice(1), 100000]
Initializing...
| Test Case | Ops/sec | |
|---|---|---|
| Set.prototype.has | | ready |
| Array.prototype.includes | | ready |
| Set.prototype.difference | | ready |
| Set.prototype.has - 1000 elements | | ready |
| Array.prototype.includes - 1000 elements | | ready |
| Set.prototype.has - 10,000 elements | | ready |
| Array.prototype.includes - 10,000 elements | | ready |
| Set.prototype.has - 100,000 elements | | ready |
| Array.prototype.includes - 100,000 elements | | ready |
| Set.prototype.has - 1,000,000 elements | | ready |
| Array.prototype.includes - 1,000,000 elements | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.