starts-with

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var startsWith = function(str, start) {
        if (str == start) return true;
        var len = str.length;
        var lenS = start.length;
        if (len < lenS) return false;
   
        return str.indexOf(start) == 0;
        },
        simple = function(str, start) {
        return str.indexOf(start) == 0;
        }
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
handMade
startsWith("Good long example", "test");
startsWith("No", "test");
startsWith("Test", "T");
pending…
simple
startsWith("Good long example", "test");
startsWith("No", "test");
startsWith("Test", "T");
pending…
native
"Good long example".startsWith("Test");
"No".startsWith("Test");
"Test".startsWith("T");
pending…

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

Compare results of other browsers

0 comments

Add a comment