Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
startsWith vs include vs substring
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/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
JS startsWith
25495.2 Ops/sec
JS includes
159296.1 Ops/sec
JS substring
290334.7 Ops/sec
Script Preparation code:
window.prefix = "%%SOME_PREFIX%%"; const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; function getRandomInt(max) { return Math.floor(Math.random() * max); } function makeRandomString(len) { var text = ""; for( var i=0; i < len; i++ ) { text += possible.charAt(getRandomInt(possible.length)); } return text; } window.allStrings = []; for (let i = 0; i < 1000; i++) { allStrings.push(window.prefix + makeRandomString(1000)); allStrings.push(makeRandomString(1000)); }
Tests:
JS startsWith
window.allStrings.forEach(s => { s.startsWith(window.prefix); })
JS includes
window.allStrings.forEach(s => { s.includes(window.prefix); })
JS substring
window.allStrings.forEach(s => { s.substring(0, window.prefix.length) === window.prefix; })