set subarray

JavaScript performance comparison

Revision 3 of this test case created

Preparation code

<script>
  l = 160 * 144;
 
  a = [];
  for(var z = 0; z < l; z++) a.push(z);
  aa = [];
 
  b = new Array(l)
  for(var z = 0; z < l; z++) b[z] = z;
  bb = new Array(l)
 
  c = new Int32Array(a);
  cc = new Int32Array(l);
 
  d = new Uint32Array(a);
  dd = new Uint32Array(l);
 
  lb = 260;
  lbb = 160;
 
</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 for
for(var z = 100; z < lb; z++) aa[z] = a[z];
 
pending…
array splice slice
Array.prototype.splice.apply(aa, [100, lbb].concat(a.slice(100, lb)));
 
pending…
arrayConst for
for(var z = 100; z < lb; z++) bb[z] = b[z];
 
pending…
arrayConst splice slice
Array.prototype.splice.apply(bb, [100, lbb].concat(b.slice(100, lb)));
 
pending…
Int32Array for
for(var z = 100; z < lb; z++) cc[z] = c[z];
 
pending…
Int32Array set subarray
cc.set(c.subarray(100, lb), 100);
 
pending…
Uint32Array for
for(var z = 100; z < lb; z++) dd[z] = d[z];
 
pending…
Uint32Array set subarray
dd.set(d.subarray(100, lb), 100);
 
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