bind vs emulate (v11)

Revision 11 of this benchmark created on


Setup

function Emulated () {
      var emulated = this
      this.test = function (one, two) {
        return emulated._test(one, two)
      }
    }
    
    Emulated.prototype._test = function (one, two) { return one + two }
    
    function Normal () {
      this.test = this._test.bind(this)
    }
    
    Normal.prototype._test = function (one, two) {
      return one + two
    }
    
    var emulated = new Emulated()
    var normal   = new Normal()

Test runner

Ready to run.

Testing in
TestOps/sec
control
normal._test(1, 2)
ready
string
normal['_test'](1, 2)
ready

Revisions

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