Raw Array vs TypedArray

JavaScript performance comparison

Test case created by Greggman

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var ra1 = [1, 2, 3];
    var ra2 = [4, 5, 6];
   
    var ta1 = new Float32Array(ra1);
    var ta2 = new Float32Array(ra2);
   
    function addRA(a, b) {
      a[0] += b[0];
      a[1] += b[1];
      a[2] += b[2];
    };
   
    function addTA(a, b) {
      a[0] += b[0];
      a[1] += b[1];
      a[2] += b[2];
    };
   
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
RawArray
addRA(ra1, ra2);
pending…
TypedArray
addTA(ta1, ta2);
pending…

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

Compare results of other browsers

0 comments

Add a comment