stringfill

JavaScript performance comparison

Test case created by juha

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
simple
function stringFill1(x, n) { 
        var s = '';
        while (s.length < n) s += x;
        return s;
        }
stringFill1('x', 1000);
pending…
without object refernce
function stringFill2(x, n) { 
        var s = '';
        while (n-- > 0) s += x;
        return s;
        }
stringFill2('x', 1000);
pending…
avoid addition
function stringFill3(x, n) { 
        var s = '';
        for (;;) {
        if (n & 1) s += x;
        n >>= 1;
        if (n) x += x;
        else break;
        }
        return s;
        }
stringFill3('x', 1000);
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. Here’s a list of current revisions for this page:

0 comments

Add a comment