Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Javascript: Case insensitive string comparison indexOf vs includes 2
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/129.0.0.0 Safari/537.36 Edg/129.0.0.0
Browser:
Chrome 129
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
toLowerCase_includes
20889.9 Ops/sec
Regex_indexOf
24866.0 Ops/sec
Script Preparation code:
var words = Array.from({ length: 1000 }, (_, i) => `word${i + 1}`); var searchString = "WORD512"; var searchStringRegex = new RegExp(searchString, 'i');
Tests:
toLowerCase_includes
const filteredCase1 = words.filter(word => word.toLowerCase().includes(searchString.toLowerCase()));
Regex_indexOf
const filteredCase2 = words.filter(word => searchStringRegex.test(word));