uuid

JavaScript performance comparison

Test case created by fmarcia

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
var tot = '';
for (var i = 0; i < 36; i++)
    tot += String.fromCharCode(97 + Math.floor(Math.random() * 26));
 
pending…
base
var c = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),
        t = new Array(36),
        r = 0,
        s,
        i;

for (i = 0; i < 36; ++i) {

        if (i == 8 || i == 13 ||  i == 18 || i == 23) {
                t[i] = '-';

        } else if (i == 14) {
                t[i] = '4';

        } else {
                if (r <= 0x02) {
                        r = 0x2000000 + (Math.random() * 0x1000000) | 0;
                }
                s = r & 0xf;
                r = r >> 4;
                t[i] = c[(i == 19) ? (s & 0x3) | 0x8 : s];
        }
}
t = t.join('');
 
pending…
best
        var i = 36,
                r = '',
                c = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
                        'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
                        'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
                i;
        while (i--)
                r += 8 == i || 13 == i || 18 == i || 23 == i ? '-' : 14 == i ? '4' :
                        c[Math.floor(Math.random() * 36)];
 
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