string.split string vs regex (v3)

Revision 3 of this benchmark created on


Setup

const testId = "hello-there"

Test runner

Ready to run.

Testing in
TestOps/sec
string.split with string parameter
testId.split('-');
ready
string.split with regex parameter
testId.split(/(?<=[0-9a-f])-/)
ready
string.find and slice
const index = testId.indexOf('-')
const targetId = index > -1 ? testId.slice(index + 1): null;
ready
String.substring
const targetId = testId.substring(0, testId.indexOf('-'))
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.