toLowerCase v. decapitalize (v117)

Revision 117 of this benchmark created by David V 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 = "";
  // Large = 10,000
  for (var i = 0; i < 10000; i++) {
        longString += i % 10;
  }
</script>

Test runner

Ready to run.

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

Revisions

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