Packed vs Holey

JavaScript performance comparison

Test case created by tkihira

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const array1 = new Array(1000000);
  for (let i = 0; i < 1000000; i++) {
    array1[i] = (Math.random() * 100) | 0;
  }
  
  const array2 = new Array();
  for (let i = 0; i < 1000000; i++) {
    array2.push((Math.random() * 100) | 0);
  }
  
  const array3 = new Array();
  for (let i = 0; i < 1000000; i++) {
    array3[i] = (Math.random() * 100) | 0;
  }
  

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
holey
let sum = 0;
for (let i = 0; i < array1.length; i++) {
    const value = array1[i];
    sum += value;
}
pending…
packed
let sum = 0;
for (let i = 0; i < array2.length; i++) {
    const value = array2[i];
    sum += value;
}
pending…
between
let sum = 0;
for (let i = 0; i < array3.length; i++) {
    const value = array3[i];
    sum += value;
}
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.

0 Comments