Empty array of complex object

JavaScript performance comparison

Revision 202 of this test case created by BuffDogg

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var sourceArray = [];
  
  for (i = 0; i < 100000; i++)
    sourceArray.push({
      a: 1,
      b: "2",
      c: [{
        z: 132,
        y: "name",
        x: "@#$tr",
        w: Math.random()
      }, {
        z: 888,
        y: "me",
        x: "Kkdw9",
        w: Math.random()
      }, {
        z: 112332,
        y: "you",
        x: "d$1%",
        w: Math.random()
      }]
    });

};
</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
shift
var arr = sourceArray.slice();

while (arr.length > 0) {
  arr.shift();
}
pending…
new array
var arr = sourceArray.slice();

arr = [];
pending…
pop
var arr = sourceArray.slice();

while (arr.length > 0) {
  arr.pop();
}
pending…
splice
var arr = sourceArray.slice();

arr.splice(0, arr.length);
pending…
length
var arr = sourceArray.slice();

arr.length = 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.

0 Comments