typed Array vs JS Array vs Object

Benchmark created by Corey Clark on


Description

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

Setup

var typed = new Float32Array([1.0,2.0,3.0]);
    
    var array = [1.0,2.0,3.0];
    
    var obj = {
        x: 1.0,
        y: 2.0,
        z: 3.0
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Typed Array
for(var i = 0; i < 100; i++){
   typed[0] *= i;
   typed[1] *= i;
   typed[2] *= i;
}
ready
JS Array
for(var i = 0; i < 100; i++){
   array[0] *= i;
   array[1] *= i;
   array[2] *= i;
}
ready
JS Object
for(var i = 0; i < 100; i++){
   obj.x *= i;
   obj.y *= i;
   obj.z *= i;
}
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