Slice vs Substr vs Substring vs [ ] Methods (v53)

Revision 53 of this benchmark created by test on


Description

This is comparing the runtimes of [ ], substr, substring, and slice in a string for large (10000 character) string size.

Preparation HTML

<script>
  var longString = "";
  for (var i = 0; i < 10; i++) {
        longString += i % 10;
  }
</script>

Test runner

Ready to run.

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

Revisions

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