startsWith (v62)

Revision 62 of this benchmark created on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
regex
r1 = (/^test/).test(s);
ready
lastIndexOf
r1 = (s.lastIndexOf("test", 0) == 0);
ready
indexOf
r1 = (s.indexOf("test") == 0);
ready
checkChars
r1 = s[0] === 't' && s[1] === 'e' && s[2] === 's' && s[3] === 't'
ready
startsWith
r1 = s.startsWith('test');
ready
slice
r1 = (s.slice(0, 4) == "test");
ready
substring
r1 = (s.substring(0, 4) == "test");
ready

Revisions

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