class-perfs (v10)

Revision 10 of this benchmark created by popomore on


Preparation HTML

<script src='http://documentcloud.github.com/underscore/underscore.js'></script>
<script src='http://documentcloud.github.com/backbone/backbone-min.js'></script>
<script src='http://seajs.org/dist/sea.js'></script>
<script src='http://assets.spmjs.org/arale/class/1.0.0/class.js'></script>
<script src='http://assets.spmjs.org/arale/class/1.1.0/class.js'></script>
<script src='http://assets.spmjs.org/arale/class/1.2.0/class.js'></script>
<script>
var Class10 = seajs.require('arale/class/1.0.0/class');
var Class11 = seajs.require('arale/class/1.1.0/class');
var Class12 = seajs.require('arale/class/1.2.0/class');
</script>
<script src="http://libs.baidu.com/mootools/1.4.5/mootools-yui-compressed.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
backbone
var Animal = Backbone.Model.extend({
  initialize: function(name) {
    this.name = name;
  },
  talk: function() {
    return 'I am ' + this.name;
  }
});

var Bird = Animal.extend({
  initialize: function(name) {
    Animal.prototype.initialize.call(this, name);
  },
  fly: function() {
    return 'I am flying';
  }
});

new Animal();
var bird = new Bird();
bird.talk();
bird.fly();
ready
mootools
var Animal = new Class({
  initialize: function(name) {
    this.name = name;
  },
  talk: function() {
    return 'I am ' + this.name;
  }
});

var Bird = new Class({
  Extends: Animal,
  initialize: function(name) {
    this.parent(name);
  },
  fly: function() {
    return 'I am flying';
  }
});

new Animal();
var bird = new Bird();
bird.talk();
bird.fly();
ready
arale/class@1.0.0
var Animal = Class10.create({
  initialize: function(name) {
    this.name = name;
  },
  talk: function() {
    return 'I am ' + this.name;
  }
});

var Bird = Animal.extend({
  initialize: function(name) {
    Bird.superclass.initialize.call(this, name);
  },
  fly: function() {
    return 'I am flying';
  }
});

new Animal();
var bird = new Bird();
bird.talk();
bird.fly();
ready
coffeescript
// Generated by CoffeeScript 1.6.2

// class Animal
//   constructor: (@name) ->
//   talk: ->
//     "I am #{@name}"

// class Bird extends Animal
//   fly: ->
//     "I am flying"

// new Animal
// bird = new Bird
// bird.talk()
// bird.fly()

(function() {
  var Animal, Bird, bird, _ref,
    __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  Animal = (function() {
    function Animal(name) {
      this.name = name;
    }

    Animal.prototype.talk = function() {
      return "I am " + this.name;
    };

    return Animal;

  })();

  Bird = (function(_super) {
    __extends(Bird, _super);

    function Bird() {
      _ref = Bird.__super__.constructor.apply(this, arguments);
      return _ref;
    }

    Bird.prototype.fly = function() {
      return "I am flying";
    };

    return Bird;

  })(Animal);

  new Animal;

  bird = new Bird;

  bird.talk();

  bird.fly();

}).call(this);
ready
arale/class@1.1.0
var Animal = Class11.create({
  initialize: function(name) {
    this.name = name;
  },
  talk: function() {
    return 'I am ' + this.name;
  }
});

var Bird = Animal.extend({
  initialize: function(name) {
    Bird.superclass.initialize.call(this, name);
  },
  fly: function() {
    return 'I am flying';
  }
});

new Animal();
var bird = new Bird();
bird.talk();
bird.fly();
ready
arale/class@1.2.0
var Animal = Class12.create({
  initialize: function(name) {
    this.name = name;
  },
  talk: function() {
    return 'I am ' + this.name;
  }
});

var Bird = Animal.extend({
  initialize: function(name) {
    Bird.superclass.initialize.call(this, name);
  },
  fly: function() {
    return 'I am flying';
  }
});

new Animal();
var bird = new Bird();
bird.talk();
bird.fly();
ready

Revisions

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