Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set.has() vs Array.includes() vs Array.indexOf() vs Array.lastIndexOf() vs Map.has()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0
Browser:
Chrome 125
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Set.has()
265114.8 Ops/sec
Array.includes()
101.9 Ops/sec
Array.indexOf()
99.9 Ops/sec
Array.lastIndexOf
60.9 Ops/sec
Map.has()
261713.0 Ops/sec
Script Preparation code:
var testArray = Array(100000).fill(0).map((v, i) => i.toString(16)); var testSet = new Set(testArray); var testMap = new Map(); testArray.forEach(v => testMap.set(v, 1)); var testCase = Array(100).fill(0).map(v => Math.floor(Math.random() * 200000).toString(16));
Tests:
Set.has()
testCase.forEach(v => testSet.has(v));
Array.includes()
testCase.forEach(v => testArray.includes(v));
Array.indexOf()
testCase.forEach(v => testArray.indexOf(v));
Array.lastIndexOf
testCase.forEach(v => testArray.lastIndexOf(v));
Map.has()
testCase.forEach(v => testMap.has(v));