TypedArray vs array unrolled

JavaScript performance comparison

Revision 2 of this test case created by Cedric Pinson

Info

Test performance using typed array and regular unrolled

Preparation code

var nbEntry=16;
var a = new Float32Array(nbEntry);
var b = [];

<script>
  var nbEntry = 16;
  var a = new Float32Array(nbEntry);
  var b = [];
  b.lenght = nbEntry;
</script>

Preparation code output

var nbEntry=16; var a = new Float32Array(nbEntry); var b = [];

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Init typed array
a[0] = 1.0;
a[1] = 1.0;
a[2] = 1.0;
a[3] = 1.0;
a[4] = 1.0;
a[5] = 1.0;
a[6] = 1.0;
a[7] = 1.0;
a[8] = 1.0;
a[9] = 1.0;
a[10] = 1.0;
a[11] = 1.0;
a[12] = 1.0;
a[13] = 1.0;
a[14] = 1.0;
a[15] = 1.0;

var suma = 0;
suma += a[0];
suma += a[1];
suma += a[2];
suma += a[3];
suma += a[4];
suma += a[5];
suma += a[6];
suma += a[7];
suma += a[8];
suma += a[9];
suma += a[10];
suma += a[11];
suma += a[12];
suma += a[13];
suma += a[14];
suma += a[15];
pending…
Init regular array
b[0] = 1.0;
b[1] = 1.0;
b[2] = 1.0;
b[3] = 1.0;
b[4] = 1.0;
b[5] = 1.0;
b[6] = 1.0;
b[7] = 1.0;
b[8] = 1.0;
b[9] = 1.0;
b[10] = 1.0;
b[11] = 1.0;
b[12] = 1.0;
b[13] = 1.0;
b[14] = 1.0;
b[15] = 1.0;
var sumb = 0;
sumb += b[0];
sumb += b[1];
sumb += b[2];
sumb += b[3];
sumb += b[4];
sumb += b[5];
sumb += b[6];
sumb += b[7];
sumb += b[8];
sumb += b[9];
sumb += b[10];
sumb += b[11];
sumb += b[12];
sumb += b[13];
sumb += b[14];
sumb += b[15];
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. Here’s a list of current revisions for this page:

0 comments

Add a comment