Serialize Integers: Bitwise versus Typed Array (v2)

Revision 2 of this benchmark created by Michael "Z" Goddard on


Setup

var dest = new ArrayBuffer(32),
        uint8 = new Uint8Array(dest),
        int32 = new Int32Array(dest),
        buffer = new ArrayBuffer( 8 ),
        buint8 = new Uint8Array( buffer ),
        bint32 = new Int32Array( buffer );

Test runner

Ready to run.

Testing in
TestOps/sec
bitwise
var i = 0x11111111;
uint8[0] = i & 0xff;
uint8[1] = ( i >> 8 ) & 0xff;
uint8[2] = ( i >> 16 ) & 0xff;
uint8[3] = ( i >> 24 ) & 0xff;
ready
int32
var i32 = new Int32Array( dest );
i32[ 0 ] = 0x11111111;
 
ready
buffer int32
bint32[ 0 ] = 0x11111111;
uint8[ 0 ] = buint8[ 0 ];
uint8[ 1 ] = buint8[ 1 ];
uint8[ 2 ] = buint8[ 2 ];
uint8[ 3 ] = buint8[ 3 ];
 
ready
direct int32
int32[ 0 ] = 0x11111111;
 
ready

Revisions

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

  • Revision 2: published by Michael "Z" Goddard on