binding (v5)

Revision 5 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
without bind
var myObj = function(){
};

myObj.prototype = {
        specialFunction: function() {

        },

        anotherSpecialFunction: function() {

        },

        getAsyncData: function(cb) {
                cb();
        },

        render: function() {
                var that = this;
                this.getAsyncData(function() {
                        that.specialFunction();
                        that.anotherSpecialFunction();
                });
        }
};

new myObj().render();
ready
with bind

var myObj = function(){
        this.fn = this.fn.bind(this);
};

myObj.prototype = {
        specialFunction: function() {

        },

        anotherSpecialFunction: function() {

        },

        getAsyncData: function(cb) {
                cb();
        },

        fn : function() {
                this.specialFunction();
                this.anotherSpecialFunction();
        },

        render: function() {
                this.getAsyncData(this.fn);
        }
};

new myObj().render();
ready

Revisions

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