You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it reasonable to use EventEmitter for publishing hundreds or thousands of different events to consumers, or is necessary to broadcast such events through another mechanism. Pre-existing performance benchmarks weren't found.
Following the benchmark guide, and a comment from someone in the PR linked below, I've made the following benchmark script but am not certain how to interpret the results --it would seem using "only" tens of event emitters is a terrible idea. Would someone with benchmark or EventEmitter experience confirm this interpretation?
benchmark script, with results as follows below
constbench=common.createBenchmark(data=>{constee=newEventEmitter();ee.setMaxListeners(Infinity);constlisteners=[];for(letk=0;k<10;k+=1)listeners.push(()=>{});consteventNames=[];for(letk=0;k<data.events;++k)eventNames.push(`dummy${k}`);// listen, emit then remove n eventsbench.start();for(leti=0;i<data.n;i+=1){for(consteventNameofeventNames){for(letk=listeners.length;k--;)ee.on(eventName,listeners[k]);}for(consteventNameofeventNames){for(letk=listeners.length;k--;)ee.emit(eventName,data);}for(consteventNameofeventNames){for(letk=listeners.length;k--;)ee.removeListener(eventName,listeners[k]);}}bench.end(data.n);},{events: [6, ...Array.from(Array(16).keys()).slice(1).map(n=>n*10)],n: [10]});
The text was updated successfully, but these errors were encountered:
iambumblehead
changed the title
do benchmarks exist for using events.EventEmitter?
reasonable to use thousands of events.EventEmitter consumers? (benchmarks added)
Nov 17, 2022
iambumblehead
changed the title
reasonable to use thousands of events.EventEmitter consumers? (benchmarks added)
reasonable to listen for thousands of different events on an EventEmitter? (benchmarks added)
Nov 17, 2022
iambumblehead
changed the title
reasonable to listen for thousands of different events on an EventEmitter? (benchmarks added)
reasonable to publish thousands of different events on an EventEmitter? (benchmarks added)
Nov 17, 2022
There has been no activity on this issue for 11 months. The help repository works best when sustained engagement moves conversation forward. The issue will be closed in 1 month. If you are still experiencing this issue on the latest supported versions of Node.js, please leave a comment.
Details
Is it reasonable to use
EventEmitter
for publishing hundreds or thousands of different events to consumers, or is necessary to broadcast such events through another mechanism. Pre-existing performance benchmarks weren't found.Following the benchmark guide, and a comment from someone in the PR linked below, I've made the following benchmark script but am not certain how to interpret the results --it would seem using "only" tens of event emitters is a terrible idea. Would someone with benchmark or EventEmitter experience confirm this interpretation?
benchmark script, with results as follows below
Node.js version
node 16 latest
Example code
Operating system
alpine linux
Scope
runtime
Module and version
Not applicable.
The text was updated successfully, but these errors were encountered: