Slice vs Substr vs Substring Methods (v70)

Revision 70 of this benchmark created on


Description

This is comparing the runtimes of substr, substring, and slice with no second argument.

Preparation HTML

<p id='nfo'></p>
<script>
  var str = "",
      len = 1e6,
      start = 10; 
  while (len--) {
        str += len;
  }
  document.getElementById('nfo').innerHTML = '"str" is ' + str.length + ' characters in length';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Substring
str.substring(start);
ready
Slice
str.slice(start);
ready
Substr
str.substr(start);
ready

Revisions

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