TypedArray vs array

JavaScript performance comparison

Test case created by Cedric Pinson

Info

Test performance using typed array and regular

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
for (var i = 0; i < nbEntry; ++i) {
 a[i] = 1.0;
}
var suma = 0;
for (var i = 0; i < nbEntry; ++i) {
 suma = a[i];
}
pending…
Init regular array
for (var i = 0; i < nbEntry; ++i) {
 b[i] = 1.0;
}
var sumb = 0;
for (var i = 0; i < nbEntry; ++i) {
 sumb = b[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. Here’s a list of current revisions for this page:

0 comments

Add a comment