startsWith JS

JavaScript performance comparison

Revision 6 of this test case created by Nicolas Donna

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  function startsWithcobbal(string, search){
    return string.substring(0, search.length) === search;
  }
  
  function startsWithMarkByers(string, search){
    return string.lastIndexOf(search, 0) === 0;
  }
  
  function startsWithVincent(string, search){
    // feeling lazy
    return (/^Lorem/).test(string);
  }
  
  function startsWithKikuchyo(string, search){
    return !string.indexOf(search);
  }
  
  function startsWithNative(string, search) {
    return string.startsWith(search);
  }
  
  theString = "Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit definiebas an eos.";

};
</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
Native
startsWithNative(theString, 'Lorem');
pending…

Revisions

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

0 Comments