index vs split

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
index
const str = "sdadad ( "
const idx = str.indexOf(' (');
const result = idx === -1 ? str : str.slice(0, idx);
ready
split
const str = "sdadad ( "
result = str.split(' (')[0];
ready

Revisions

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