Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Search in array of strings
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/136.0.0.0 Safari/537.36 Edg/136.0.0.0
Browser:
Chrome 136
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
IndexOf
460K/s
Includes
317K/s
ForEach with === with length check
286K/s
ForEach with ===
227K/s
ForEach with ==
136K/s
View exact numbers
Test name
Executions per second
✓
IndexOf
460,155 Ops/sec
Includes
317,222 Ops/sec
ForEach with === with length check
285,829 Ops/sec
ForEach with ===
226,564 Ops/sec
ForEach with ==
135,990 Ops/sec
Script Preparation code:
var str = '1234567'; var arr = []; for (i = 0; i < 1000; i++) { arr.push([...Array(4 + Math.floor(Math.random() * 8))].map(i => (~~(Math.random() * 36)).toString(36)).join('')) }
Tests:
IndexOf
arr.indexOf(str)
Includes
arr.includes(str)
ForEach with === with length check
arr.forEach(s => { if (s.length === str.length && s === str) console.log('Finded!'); })
ForEach with ===
arr.forEach(s => { if (s === str) console.log('Finded!'); })
ForEach with ==
arr.forEach(s => { if (s == str) console.log('Finded!'); })