startsWith

JavaScript performance comparison

Revision 29 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
indexOf
r1 = (s.toLowerCase().indexOf("TEST".toLowerCase()) == 0);
r2 = (s.toLowerCase().indexOf("not There".toLowerCase()) == 0);
pending…
lastIndexOf
r1 = (s.toLowerCase().lastIndexOf("tEst".toLowerCase(), 0) == 0);
r2 = (s.toLowerCase().lastIndexOf("not There".toLowerCase(), 0) == 0);
pending…
substring
r1 = (s.toLowerCase().substring(0, "tEst".length) == "tEst".toLowerCase());
r2 = (s.toLowerCase().substring(0, "noT there".length) == "noT there".toLowerCase());
pending…
slice
r1 = (s.toLowerCase().slice(0, "tEst".length) == "tEst".toLowerCase());
r2 = (s.toLowerCase().slice(0, "nOt there".length) == "nOt there".toLowerCase());
pending…
regex
r1 = (/^test/).test(s);
r2 = (/^not there/).test(s);
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