Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
startsWith vs include
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 17
Operating system:
iOS 17.2.1
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
JS startsWith
6784.5 Ops/sec
JS includes
1456.0 Ops/sec
JS substring
3785.8 Ops/sec
Script Preparation code:
window.prefix = "%%CHAT_TRANSCRIPT%%"; 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("%%CHAT_TRANSCRIPT%%\n\n" + 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; })