Instruction Decode (v2)

Revision 2 of this benchmark created on


Setup

opcode = Math.random() * 2 ** 31;

Test runner

Ready to run.

Testing in
TestOps/sec
Lookup table
const instructionSizeTable = [3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 4, 3];
const size = instructionSizeTable[opcode & 0xf]; 
ready
Bitwise
    const size =  (opcode & 0xf) === 0xe ? 4 : (opcode & 0xc) === 0x8 || ((opcode & 0xc) === 0xc && (opcode & 0x2) === 0) ? 2 : 3; 


ready
Lookup table (Uint8Array)
const instructionSizeTable = new Uint8Array([3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 4, 3]);
const size = instructionSizeTable[opcode & 0xf]; 
ready

Revisions

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