Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Array.find vs. Set.has
Compares a performance of Array.find on a small number of items
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Set.has existing
4.1M/s
Set.has non-Existing
4.0M/s
Array.find existing
2.0M/s
Array.find non-existing
1.2M/s
View exact numbers
Test name
Executions per second
✓
Set.has existing
4,114,897 Ops/sec
Set.has non-Existing
3,976,165 Ops/sec
Array.find existing
2,045,721 Ops/sec
Array.find non-existing
1,151,168 Ops/sec
Script Preparation code:
const SOURCE_DATA = ['one', 'two', 'three', 'four', 'five', 'six']; const arr = Array.from(SOURCE_DATA); const set = new Set(SOURCE_DATA); const existingItem = 'three'; const nonExistingItem = 'nine'; window.testData = { SOURCE_DATA, arr, set, existingItem, nonExistingItem };
Tests:
Array.find existing
window.testData.arr.find(e => e === window.testData.existingItem);
Array.find non-existing
window.testData.arr.find(e => e === window.testData.nonExistingItem);
Set.has existing
window.testData.set.has(window.testData.existingItem)
Set.has non-Existing
window.testData.set.has(window.testData.nonExistingItem)