typed Array vs JS Array vs Object (v3)

Revision 3 of this benchmark created by Nexii Malthus on


Description

Testing computational speed for using Typed Array, JSON Array Object and JS Object

Preparation HTML

<script src="https://www.calormen.com/polyfill/typedarray.js"></script>

Setup

var testSize = 2000;
    
    var ui8 = new Uint8Array(testSize);
    var i8 = new Int8Array(testSize);
    var ui16 = new Uint16Array(testSize);
    var i16 = new Int16Array(testSize);
    var ui32 = new Uint32Array(testSize);
    var i32 = new Int32Array(testSize);
    var f32 = new Float32Array(testSize);
    var f64 = new Float64Array(testSize);
    
    var array = new Array(testSize);
    
    var obj = {};
    var i = testSize; while(i--) obj[i] = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
Uint8
for(var i = 0; i < testSize; i++) ui8[i] = i*2;
ready
Int8
for(var i = 0; i < testSize; i++) i8[i] = i*2;
ready
Uint16
for(var i = 0; i < testSize; i++) ui16[i] = i*2;
ready
Int16
for(var i = 0; i < testSize; i++) i16[i] = i*2;
ready
Uint32
for(var i = 0; i < testSize; i++) ui32[i] = i*2;
ready
Int32
for(var i = 0; i < testSize; i++) i32[i] = i*2;
ready
Float32
for(var i = 0; i < testSize; i++) f32[i] = i*2;
ready
Float64
for(var i = 0; i < testSize; i++) f64[i] = i*2;
ready
Array
for(var i = 0; i < testSize; i++) array[i] = i*2;
ready
Object
for(var i = 0; i < testSize; i++) obj[i] = i*2;
ready

Revisions

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

  • Revision 1: published by Corey Clark on
  • Revision 2: published on
  • Revision 3: published by Nexii Malthus on
  • Revision 4: published by bluefireuoop on
  • Revision 5: published by bluefireuoop on
  • Revision 6: published by Jason Oster on