prototype vs closures (v54)

Revision 54 of this benchmark created by Dillon Uzar on


Setup

function get_name() {
    return this.name;
  }
  
  function set_name(name) {
    this.name = name;
  }
  
  function Person(name) {
    this.name = name;
  }
  Person.prototype.get_name = get_name;
  Person.prototype.set_name = set_name;
  
  var person = function(name) {
    return {
      'name': name,
      'get_name': get_name,
      'set_name': set_name
    };
  };
  
  var p = new Person('John');
  var c = person('John');

Test runner

Ready to run.

Testing in
TestOps/sec
Prototype init
p = new Person('John');
ready
Closure init
c = person('John');
ready
Prototype read
p.get_name();
ready
Closure read
c.get_name();
ready
Prototype write
p.set_name('Jane');
ready
Closure write
c.set_name('Jane');
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.