startsWith

JavaScript performance comparison

Revision 62 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  a = ["test"];
  for (var i = 0; i < 10000; i++) {
    a.push("some other stuff");
  }
  s = a.join();

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
regex
r1 = (/^test/).test(s);
pending…
lastIndexOf
r1 = (s.lastIndexOf("test", 0) == 0);
pending…
indexOf
r1 = (s.indexOf("test") == 0);
pending…
checkChars
r1 = s[0] === 't' && s[1] === 'e' && s[2] === 's' && s[3] === 't'
pending…
startsWith
r1 = s.startsWith('test');
pending…
slice
r1 = (s.slice(0, 4) == "test");
pending…
substring
r1 = (s.substring(0, 4) == "test");
pending…

Compare results of other browsers

Revisions

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

0 Comments