Typed Arrays: set vs. indices

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var m44 = new Float32Array(16);
    var dm44 = new Float32Array(16);
   
    var medium = new Float32Array(1024);
    var dmedium = new Float32Array(1024);
   
    var big = new Float32Array(1048576);
    var dbig = new Float32Array(1048576);
   
};
</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
Setting a Typed Small Array
dm44.set(m44);
 
pending…
Setting Indices of a Small Typed Array, Explicitly
dm44[0] = m44[0];
dm44[1] = m44[1];
dm44[2] = m44[2];
dm44[3] = m44[3];
dm44[4] = m44[4];
dm44[5] = m44[5];
dm44[6] = m44[6];
dm44[7] = m44[7];
dm44[8] = m44[8];
dm44[9] = m44[9];
dm44[10] = m44[10];
dm44[11] = m44[11];
dm44[12] = m44[12];
dm44[13] = m44[13];
dm44[14] = m44[14];
dm44[15] = m44[15];
 
pending…
Setting Indices of a Small Typed Array, Looping
for (var i = 0; i < 16; ++i)
    dm44[i] = m44[i];
 
pending…
Setting a Medium Typed Array
dmedium.set(medium);
 
pending…
Setting a Medium Typed Array, Looping
for (var i = 0; i < 1024; ++i)
    dmedium[i] = medium[i];
 
pending…
Setting a Large Typed Array
dbig.set(big);
 
pending…
Setting a Large Typed Array, Looping
for (var i = 0; i < 1048576; ++i)
    dbig[i] = big[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