delete vs new object

JavaScript performance comparison

Revision 42 of this test case created by

Preparation code

<script>
  'use strict';
  var template = {
    a: 1,
    b: 2,
    c: 3,
    d: 4,
    e: 5,
    f: 6,
    g: 7,
    h: 8,
    i: 9,
    j: '10',
    k: 11,
    l: '12',
    m: function() {
      return 13;
    },
    n: 14,
    o: function() {
      return '15';
    }
  };

</script>
      
<script>
Benchmark.prototype.setup = function() {
  var o = {};
  for (var x in template) {
    o[x] = template[x];
  }

};
</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
Delete properties
for (var key in o) {
  if (key < 'n')
    delete o[key];
}
pending…
Copy object
var o2 = {};
for (var key in o) {
  if (key >= 'n')
    o2[key] = o[key];
}
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