PubSubSubcribe

JavaScript performance comparison

Revision 6 of this test case created

Info

Comparing the subscribe speeds of mroderick/PubSubJs, ifandelse/PostalJs, and uxder/radiojs

Preparation code

<script src="https://raw.github.com/uxder/Radio/master/radio.min.js">
</script>
<script src="https://raw.github.com/mroderick/PubSubJS/master/src/pubsub.js">
</script>
<script src="https://raw.github.com/postaljs/postal.js/master/example/standard/js/underscore.js">
</script>
<script src="https://raw.github.com/postaljs/postal.js/master/example/standard/js/postal.min.js">
</script>
<script type="text/javascript">
  var mroderick = PubSub;
  var uxder = radio;
  var ifandelse = postal.channel("channel");

  var sub1;
  var sub2;
  var sub3;
</script>
<script>
Benchmark.prototype.teardown = function() {
    if (sub1) {
      // Unsubscribe pubsubjs subscription
      mroderick.unsubscribe(sub1);
    }
   
    if (sub2) {
      // unsubscribe postal subscription
      sub2.unsubscribe();
    }
   
    if (sub3) {
      // Unsubscribe radio subscription
      uxder("topic").unsubscribe(sub3);
    }
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
mroderick pubsub
sub1 = mroderick.subscribe("test", function() {});
pending…
ifandelse postaljs
sub2 = ifandelse.subscribe({
  topic: "topic",
  callback: function() {}
});
pending…
uxder Radio
uxder("topic").subscribe(sub3 = function() {});
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment