Array copy vs typed copy

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var a = [], b = [];
    a.length = 100000;
    b.length = a.length;
   
    var c = new Uint8Array(800000);
    var d = new Uint8Array(800000);
   
    var e = new Uint32Array(200000);
    var f = new Uint32Array(200000);
   
    var g = new Float64Array(100000);
    var h = new Float64Array(100000);
};
</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
Array copy
for(var rep=0;rep<100000;rep++){
a[rep] = b[rep];
}
pending…
Uint8Array
c.set(d, 0);
pending…
Uint32Aray
e.set(f, 0);
pending…
Float64Array
g.set(h, 0);
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