class-perfs (v4)

Revision 4 of this benchmark created 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://aralejs.org/dist/seajs/1.1.0/sea.js'>
</script>
<script src='http://aralejs.org/dist/class/0.9.0/class.js'>
</script>
<script>
  seajs.use('class/0.9.0/class', function(Class) {
    seajs.Class = Class;
  });
</script>
<script src='http://mootools.net/download/get/mootools-core-1.4.5-full-nocompat.js'>
</script>
<script src="http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js">
</script>
<script>YUI().use('base', function (Y) { window.Y = Y; });</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
var Animal = seajs.Class.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
yui
function Animal(config) {
  Animal.superclass.constructor.apply(this, arguments);
}

Y.extend(Animal, Y.Base, {
  initializer: function(name) {
    this.name = name;
  }
  talk: function() {
    return 'I am ' + this.name;
  }
});

function Bird(config) {
  Bird.superclass.constructor.apply(this, arguments);
}

Y.extend(Bird, Animal, {
  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.