jQuery PubSub - window vs object

Benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<!--<script src="//raw.github.com/gist/661855/9ef0e862a574c5148e5945cb8306969f6d642fda/jquery.ba-tinypubsub.js">
</script>-->
<script>
(function(jQuery){
  var o = jQuery({});
  jQuery.each({ 
    "subscribe" : "bind", 
    "unsubscribe" : "unbind", 
    "publish" : "trigger" 
  }, function ( fn, api ) {
    jQuery[ fn ] = function() {
      o[ api ].apply( o, arguments );
    };
  });
})(jQuery);
</script>

Setup

var callback = function() {}
        
    var DISPATCHER = {};
    
    $(function() {
      $(window).bind('chris', callback);
      $.subscribe('chris', callback);
    });

Test runner

Ready to run.

Testing in
TestOps/sec
window
$(window).trigger('chris');
ready
object
$.publish('chris');
ready

Revisions

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