Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
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/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
11 months ago
Test name
Executions per second
Array.find existing
105773696.0 Ops/sec
Array.find non-existing
96165904.0 Ops/sec
Set.has existing
78036760.0 Ops/sec
Set.has non-Existing
45470256.0 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)