I definitely wouldn't recommend something like this if you have to create many listeners at a time - creating new listeners is quite expensive as it has to roll-out all the loops then compile the new `emit` function.
Small use case, but it could be really useful for protocol parsers or the like, where you set up one bunch of listeners per 'instance'. On Tue, Jun 18, 2013 at 03:54:52AM +0300, Dan Milon wrote: > `.on` seems a pretty heavy operation given that it crafts a new function > every time. In the real world I assume it's a pretty hot path (take data > listeners for http for example). > > It would be interesting to provide a real-world test, with `.on` > benchmarked too. > > On 06/18/2013 03:38 AM, Tim Smart wrote: > > For anyone to play around with and maybe develop further: > > > > https://gist.github.com/tim-smart/5801765 > > > > Has some benchmarks at the bottom of the file, run it and see the results :) > > > > Idea came from felixge's performance talk on the MySQL client - would love > > to > > see where this goes as a high-performance simple event-emitter. > > > > Tim > > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
