Multiple Listeners vs. Multiple Dispatches
JavaScript performance comparison
Info
When handling dispatching custom events, is it faster to register each callback as a separate listener or to dispatch the event multiple times.
Preparation code
<script>
var
listenTo = document
listenerCount = 100,
listeners = [],
listenerFactory = function(fn) {
return function(event) {
event.target.removeEventListener(
event.type, arguments.callee, false)
fn()
}
}
function listener(event) {
this
}
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Individual Handlers |
|
pending… |
Multiple Dispatches |
|
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 W Alexander
- Revision 2: published
- Revision 3: published
0 comments