Is proxy worth it

Benchmark created by cody lindley on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script><div>module method click me!</div>

Test runner

Ready to run.

Testing in
TestOps/sec
With proxy
myApp = {};

myApp.module = {

 $div: $('div'),

 init: function() {
  this.$div.mousedown($.proxy(this.moduleMethod, this)).trigger('mousedown');
 },

 moduleMethod: function(e) {
  console.log(this);
 }
}

myApp.module.init();
ready
Without proxy
myApp = {};

myApp.module = {

 $div: $('div'),

 init: function() {
  this.$div.mousedown(this.moduleMethod).trigger('mousedown');
 },

 moduleMethod: function(e) {
  console.log(myApp.Module);
 }
}

myApp.module.init();
ready

Revisions

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

  • Revision 1: published by cody lindley on