delete vs. _.omit

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script src="//underscorejs.org/underscore.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var datum = {
      a: 1,
      b: 2,
      c: 3,
      d: 4,
      e: 5,
      f: 6,
      g: 7
    };
     
};
</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
delete dot
delete datum.a;
pending…
delete brackets
delete datum['a'];
pending…
underscore omit
datum = _.omit(datum, 'a');
pending…
delete dot multiple
delete datum.a;
delete datum.b;
delete datum.c;
delete datum.d;
pending…
delete brackets multiple
delete datum['a'];
delete datum['b'];
delete datum['c'];
delete datum['d'];
pending…
underscore omit multiple
datum = _.omit(datum, ['a','b','c','d']);
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