Slower in Chrome 23

JavaScript performance comparison

Test case created by Paul Holden

Info

This snippet of code seems to be slower in Chrome 23 than in Chrome 21?

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function CPU() {
        this.pc = 0;
        this.delayPC = 0;
        this.stuffToDo = 0;
        this.nextPC = 0;
    }
   
    var cpu0 = new CPU();
    var ram = new Uint8Array(8*1024*1024);
    var rlo = new Int32Array(32);
    var rhi = new Int32Array(32);
   
    function reset() {
        cpu0.pc = 0x802003f4;
        cpu0.delayPC = 0;
        cpu0.nextPC = 0;
        cpu0.stuffToDo = 0;
   
        rlo[0] = 0x00000000;
        rlo[1] = 0x00008000;
        rlo[2] = 0x00000000;
        rlo[3] = 0x00000000;
        rlo[4] = 0x00026000;
        rlo[5] = 0x00000900;
        rlo[6] = 0x00031600;
        rlo[7] = 0x00000900;
        rlo[8] = 0x000018c5;
        rlo[9] = 0x800b03ea;
        rlo[10] = 0x00000100;
        rlo[11] = 0x00000000;
        rlo[12] = 0x000003ec;
        rlo[13] = 0x00000001;
        rlo[14] = 0x0000008a;
        rlo[15] = 0x000000db;
        rlo[16] = 0x00000000;
        rlo[17] = 0x00000000;
        rlo[18] = 0x00000000;
        rlo[19] = 0x00000000;
        rlo[20] = 0x00000000;
        rlo[21] = 0x00000000;
        rlo[22] = 0x00000000;
        rlo[23] = 0x00000000;
        rlo[24] = 0x80209144;
        rlo[25] = 0x800b0000;
        rlo[26] = 0xa430000c;
        rlo[27] = 0x00000aaa;
        rlo[28] = 0x00000000;
        rlo[29] = 0x80239ad0;
        rlo[30] = 0x80239ad0;
        rlo[31] = 0x802002b8;
        rhi[0] = 0x00000000;
        rhi[1] = 0x00000000;
        rhi[2] = 0x00000000;
        rhi[3] = 0x00000000;
        rhi[4] = 0x00000000;
        rhi[5] = 0x00000000;
        rhi[6] = 0x00000000;
        rhi[7] = 0x00000000;
        rhi[8] = 0x00000000;
        rhi[9] = 0xffffffff;
        rhi[10] = 0x00000000;
        rhi[11] = 0x00000000;
        rhi[12] = 0x00000000;
        rhi[13] = 0x00000000;
        rhi[14] = 0x00000000;
        rhi[15] = 0x00000000;
        rhi[16] = 0x00000000;
        rhi[17] = 0x00000000;
        rhi[18] = 0x00000000;
        rhi[19] = 0x00000000;
        rhi[20] = 0x00000000;
        rhi[21] = 0x00000000;
        rhi[22] = 0x00000000;
        rhi[23] = 0x00000000;
        rhi[24] = 0xffffffff;
        rhi[25] = 0xffffffff;
        rhi[26] = 0xffffffff;
        rhi[27] = 0x00000000;
        rhi[28] = 0x00000000;
        rhi[29] = 0xffffffff;
        rhi[30] = 0xffffffff;
        rhi[31] = 0xffffffff;
    }
   
   
    function load_u16(ram, addr) {
        if (addr < -2139095040) {
                var phys = (addr + 0x80000000) | 0;  // NB: or with zero ensures we return an SMI if possible.
                return (ram[phys] << 8) | ram[phys+1];
        }
        return lhu_slow(addr);
    }
    function store_16(ram, addr, value) {
        if (addr < -2139095040) {
                var phys = (addr + 0x80000000) | 0;  // NB: or with zero ensures we return an SMI if possible.
                ram[phys  ] = value >> 8;
                ram[phys+1] = value;
        } else {
                sh_slow(addr, value);
        }
    }
   
    function fragment_0x802003f4_15(c, rlo, rhi, ram) {
        var result = rlo[6] + rlo[10];
        rlo[6] = result;
        rhi[6] = result >> 31;
        if (c.delayPC) { c.pc = c.delayPC; c.delayPC = 0; } else { c.pc = 0x802003f8; }
        if (c.pc !== 0x802003f8) { return 1; }
   
        var result = rlo[6] >>> 8;
        rlo[8] = result;
        rhi[8] = result >> 31;
   
        var result = rlo[7] + rlo[11];
        rlo[7] = result;
        rhi[7] = result >> 31;
   
        rlo[8] = rlo[8] & 255;
        rhi[8] = 0;
   
        rlo[9] = rlo[7] & 65280;
        rhi[9] = 0;
   
        rlo[8] = rlo[8] | rlo[9];
        rhi[8] = rhi[8] | rhi[9];
   
        var result = rlo[25] + rlo[12];
        rlo[9] = result;
        rhi[9] = result >> 31;
   
        var result = rlo[8] << 1;
        rlo[8] = result;
        rhi[8] = result >> 31;
   
        var result = rlo[12] + 2;
        rlo[12] = result;
        rhi[12] = result >> 31;
   
        var result = rlo[24] + rlo[8];
        rlo[8] = result;
        rhi[8] = result >> 31;
   
        var result = rlo[14] - rlo[13];
        rlo[14] = result;
        rhi[14] = result >> 31;
   
        c.pc = 0x80200420;
        c.nextPC = 0x80200424;
        rlo[8] = load_u16(ram, rlo[8] + 0);
        rhi[8] = 0;
        c.pc = c.nextPC;
        if (c.stuffToDo) { return 12; }
        if (c.pc !== 0x80200424) { return 12; }
   
        c.nextPC = 0x80200428;
        store_16(ram, rlo[9] + 0, rlo[8]);
        c.pc = c.nextPC;
        if (c.stuffToDo) { return 13; }
        if (c.pc !== 0x80200428) { return 13; }
   
        if (rhi[14] !== 0 ||
            rlo[14] !== 0 ) {
          c.delayPC = 0x802003f4;
        }
        c.pc = 0x8020042c;
        if (c.pc !== 0x8020042c) { return 14; }
   
        if (c.delayPC) { c.pc = c.delayPC; c.delayPC = 0; } else { c.pc = 0x80200430; }
        if (c.pc !== 0x802003f4) { return 15; }
   
        return 15;
    }
   
};
</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
A
reset();
fragment_0x802003f4_15(cpu0, rlo, rhi, ram);
pending…
B
reset();
fragment_0x802003f4_15(cpu0, rlo, rhi, ram);
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