Float32Array vs Array

JavaScript performance comparison

Revision 2 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var f32_10000 = new Float32Array(10000);
  var arr_10000 = new Array(10000);
  var f32_1000 = new Float32Array(1000);
  var arr_1000 = new Array(1000);
  var f32_100 = new Float32Array(100);
  var arr_100 = new Array(100);
  var f32_10 = new Float32Array(10);
  var arr_10 = new Array(10);

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
1x10,000 - Float32Array rw + creation
var f32 = new Float32Array(10000);
for (var i=0; i<10000; i++) f32[i] = 0.1;
for (var i=0; i<10000; i++) f32[i] = f32[i]*f32[i];
pending…
1x 10,000 - Float32Array rw
for (var i=0; i<10000; i++) f32_10000[i] = 0.1;
for (var i=0; i<10000; i++) f32_10000[i] = f32_10000[i]*f32_10000[i];
pending…
1x10,000 - Array rw
for (var i=0; i<10000; i++) arr_10000[i] = 0.1;
for (var i=0; i<10000; i++) arr_10000[i] = arr_10000[i]*arr_10000[i];
pending…
1x10,000 - Array rw + creation
var arr = new Array(10000);
for (var i=0; i<10000; i++) arr[i] = 0.1;
for (var i=0; i<10000; i++) arr[i] = arr[i]*arr[i];
pending…
10 x 1,000 - Float32Array rw
for (var k=0; k<10; k++) {
  for (var i=0; i<1000; i++) f32_1000[i] = 0.1;
  for (var i=0; i<1000; i++) f32_1000[i] = f32_1000[i]*f32_1000[i];
}
pending…
10 x 1,000 - Array rw
for (var k=0; k<10; k++) {
  for (var i=0; i<1000; i++) arr_1000[i] = 0.1;
  for (var i=0; i<1000; i++) arr_1000[i] = arr_1000[i]*arr_1000[i];
}
pending…
10x1,000 - Float32Array rw + creation
for (var k=0; k<10; k++) {
  var f32_1000 = new Float32Array(1000);
  for (var i=0; i<1000; i++) f32_1000[i] = 0.1;
  for (var i=0; i<1000; i++) f32_1000[i] = f32_1000[i]*f32_1000[i];
}
pending…
10x1,000 - Array rw + creation
for (var k=0; k<10; k++) {
  var arr_1000 = new Array(1000);
  for (var i=0; i<1000; i++) arr_1000[i] = 0.1;
  for (var i=0; i<1000; i++) arr_1000[i] = arr_1000[i]*arr_1000[i];
}
pending…
100x100 - Float32Array rw
for (var k=0; k<100; k++) {
  for (var i=0; i<100; i++) f32_100[i] = 0.1;
  for (var i=0; i<100; i++) f32_100[i] = f32_100[i]*f32_100[i];
}
pending…
100x100 - Array rw
for (var k=0; k<100; k++) {
  for (var i=0; i<100; i++) arr_100[i] = 0.1;
  for (var i=0; i<100; i++) arr_100[i] = arr_100[i]*arr_100[i];
}
pending…
100x100 - Float32Array rw + creation
for (var k=0; k<100; k++) {
  var f32_100 = new Float32Array(100);
  for (var i=0; i<100; i++) f32_100[i] = 0.1;
  for (var i=0; i<100; i++) f32_100[i] = f32_100[i]*f32_100[i];
}
pending…
100x100 - Array rw + creation
for (var k=0; k<100; k++) {
  var arr_100 = new Array(100);
  for (var i=0; i<100; i++) arr_100[i] = 0.1;
  for (var i=0; i<100; i++) arr_100[i] = arr_100[i]*arr_100[i];
}
pending…
1,000x10 - Float32Array rw
for (var k=0; k<1000; k++) {
  for (var i=0; i<10; i++) f32_10[i] = 0.1;
  for (var i=0; i<10; i++) f32_10[i] = f32_10[i]*f32_10[i];
}
pending…
1,000x10 - Array rw
for (var k=0; k<1000; k++) {
  for (var i=0; i<10; i++) arr_10[i] = 0.1;
  for (var i=0; i<10; i++) arr_10[i] = arr_10[i]*arr_10[i];
}
pending…
1,000x100 - Float32Array rw + creation
for (var k=0; k<1000; k++) {
  var f32_10 = new Float32Array(10);
  for (var i=0; i<10; i++) f32_10[i] = 0.1;
  for (var i=0; i<10; i++) f32_10[i] = f32_10[i]*f32_10[i];
}
pending…
1,000x10 - Array rw + creation
for (var k=0; k<1000; k++) {
  var arr_10 = new Array(10);
  for (var i=0; i<10; i++) arr_10[i] = 0.1;
  for (var i=0; i<10; i++) arr_10[i] = arr_10[i]*arr_10[i];
}
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.

0 Comments