Object vs. Seal vs. Freeze

JavaScript performance comparison

Test case created by Oncle Tom

Info

I was wondering why my tests took much more time than average.

Seal was adding more security… but more latency too.

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Regular Object Constructor
new(function Dummy(args) {
  this.foo = 'wont be foo';
  this.emptiness = [];
  this.mind_changer = false;
})({
  foo: 'will be foo',
  mind_changer: true
})
pending…
Sealing Object Constructor
new(function Dummy(args) {
  this.foo = 'wont be foo';
  this.emptiness = [];
  this.mind_changer = false;

  Object.seal(this);
})({
  foo: 'will be foo',
  mind_changer: true
})
pending…
Freezing Object Constructor
new(function Dummy(args) {
  this.foo = 'wont be foo';
  this.emptiness = [];
  this.mind_changer = false;

  Object.freeze(this);
})({
  foo: 'will be foo',
  mind_changer: true
})
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