A Comparison of JS Publish/Subscribe Approaches
JavaScript performance comparison
Info
A Comparison of JS Publish/Subscribe Approaches
More info: publish/subscribe on Wikipedia.
Compared:
Preparation code
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript">
</script>
<script src="https://raw.github.com/mroderick/PubSubJS/master/src/pubsub.js" type="text/javascript">
</script>
<script src="https://raw.github.com/kuwabarahiroshi/bloody-jquery-plugins/master/pubsub.js" type="text/javascript">
</script>
<script src="https://raw.github.com/phiggins42/bloody-jquery-plugins/55e41df9bf08f42378bb08b93efcb28555b61aeb/pubsub.js" type="text/javascript">
</script>
<script src="https://raw.github.com/gist/1695338/736bcf94f9226d975fce3ad4f2bc08ccbf176bad/pubsub.js" type="text/javascript">
</script>
<script src="https://raw.github.com/appendto/amplify/master/core/amplify.core.js" type="text/javascript">
</script>
<script src="https://raw.github.com/maccman/spine/master/lib/spine.js" type="text/javascript">
</script>
<script src="https://raw.github.com/richardscarrott/ply/master/src/core.js" type="text/javascript">
</script>
<script type="text/javascript">
window.callback = function () {};
window.payload = {
somekey: 'some value'
};
jQuery(function() {
for (var i = 0; i < 10; i++) {
jQuery(window).bind('my-event-' + i, callback);
PubSub.subscribe('my-event-' + i, callback);
jQuery.subscribe('my-event-' + i, callback);
Events.subscribe('my-event-' + i, callback);
App.subscribe('my-event-' + i, callback);
amplify.subscribe('my-event-' + i, callback);
Spine.bind('my-event-' + i, callback);
Ply.core.listen('my-event-' + i, callback);
}
});
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
jQuery Events |
|
pending… |
PubSubJS |
|
pending… |
jQuery PubSub plugin |
|
pending… |
Pure JS PubSub |
|
pending… |
Darcy Clarke |
|
pending… |
Amplify Pub/Sub |
|
pending… |
Spine Events |
|
pending… |
Ply Notify/Listen |
|
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:
- Revision 1: published by Morgan Roderick
- Revision 3: published by Morgan Roderick
- Revision 4: published
- Revision 5: published by Stephen Crosby
- Revision 6: published by Andrew Betts
- Revision 8: published
- Revision 11: published
- Revision 12: published by Morgan Roderick
- Revision 18: published
- Revision 19: published
- Revision 20: published
- Revision 21: published
- Revision 22: published by Richard and last updated
- Revision 24: published by Hiroshi Kuwabara
- Revision 25: published
- Revision 26: published by s0ber
- Revision 30: published by Jakeb
- Revision 31: published by Jakeb
- Revision 34: published by pmelande
- Revision 36: published by pmelande
- Revision 37: published by pmelande
- Revision 39: published by Jakeb
- Revision 40: published by Jakeb
- Revision 41: published by pmelande
- Revision 43: published by Morgan Roderick
- Revision 44: published by Jakeb
- Revision 47: published by asyraf
- Revision 50: published by pmelande
- Revision 51: published by pmelande
- Revision 52: published by Jakeb
- Revision 53: published
- Revision 54: published
- Revision 55: published
- Revision 56: published by Anas Nakawa
- Revision 57: published
- Revision 58: published
- Revision 59: published by Burke
- Revision 60: published by Tobias Haustein
- Revision 62: published by vlazar
- Revision 64: published by Stuart
- Revision 66: published by Brandon Papworth
- Revision 67: published
- Revision 68: published
- Revision 69: published
- Revision 70: published
- Revision 73: published
- Revision 74: published
- Revision 75: published by Wojciech Dłubacz
- Revision 76: published
- Revision 77: published
- Revision 78: published by Wojciech Dłubacz
- Revision 79: published
- Revision 80: published by Sparda
- Revision 82: published
- Revision 83: published by Bruno
- Revision 85: published
- Revision 86: published
- Revision 87: published
- Revision 88: published
- Revision 89: published
- Revision 90: published
- Revision 91: published
- Revision 92: published by Caleb Gilbert
- Revision 93: published
- Revision 94: published
- Revision 95: published
- Revision 97: published by Brandon Papworth
- Revision 99: published
- Revision 100: published
- Revision 101: published
- Revision 102: published
0 comments