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

Revision 78 of this benchmark created on


Description

This is comparing the runtimes of substr, substring, and slice in a short string.

Preparation HTML

<script>
  var string = '__function__0.32131241231';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Substring
for (i = 0; i < string.length; i++) {
  string.substring(i);
}
ready
Slice
for (i = 0; i < string.length; i++) {
  string.slice(i);
}
ready
Substr
for (i = 0; i < string.length; i++) {
  string.substr(i);
}
ready

Revisions

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