Split vs substring (v2)

Revision 2 of this benchmark created on


Description

Attempt to get 'boo'

Preparation HTML

<script>
  var test = 'blah-boo';
  var test1;
  var test2;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Split
test1 = test.split('-')[1];
ready
Substring
test2 = test.substring(test.indexOf('-') + 1, test.length)
ready
Substring where blah is fixed length
test2 = test.substring(5, test.length)
ready
Substring where blah is fixed and length is fixed
test2 = test.substring(5, 8)
ready
Substring blah
test2 = test.substring(0, test.indexOf('-'))
ready

Revisions

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