Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Emitter performance for no-listener case #80

Closed
jonathanolson opened this issue Dec 8, 2015 · 3 comments
Closed

Check Emitter performance for no-listener case #80

jonathanolson opened this issue Dec 8, 2015 · 3 comments

Comments

@jonathanolson
Copy link
Contributor

It may be beneficial to wrap emit() bodies with a check to see if there are currently any listeners that would be notified.

Some bottlenecks in Kite are currently with Events that would be emitting with no listeners, so it would be beneficial if this is a fast operation.

Worth a performance check for "no listeners" and "some listeners" both before and after adding a guard, to make sure we don't compromise other performance.

@samreid
Copy link
Member

samreid commented Dec 29, 2016

Another possibility: for client code that is a bottleneck and likely to have no observers, put the check in the client code. For instance, in this case, Kite could check if there are listeners before calling emit.

@samreid
Copy link
Member

samreid commented Dec 10, 2018

I noted that in Graphing Quadratics, listeners with no emitters (in the emit call) were called thousands of times, so it seems best to check for the existence of listeners and avoid push/pop. I also ran a test for the time form when Sim constructor is called to when Profiler.start( self ); is called. Here is the raw data:

with guards
1000
961
976
855
833
781
815
896
770
834
770
848
868

without guards
1145
833
860
830
1162
783
815
864
873
863
952
846
902
781

with guards
1406
963
890
837
805
836
882
783
918
827
971
873
797

The averages are:
guard 1: 862
no guard: 893
guard 2: 906

Note the first several samples are not in steady state and occur while the browser is optimizing:

image

If we look at this tail:
image

The averages are
guard 1: 822
no guard: 853
guard 2: 860

This looks to be "in the noise" with a slight preference for the guard, however, the Wilcoxon signed rank test https://www.socscistatistics.com/tests/signedranks/Default2.aspx on the tails of the data says this is statistically significant.

It seems a step in the right direction, so I'll commit.

@samreid
Copy link
Member

samreid commented Dec 10, 2018

I should note, all of those tests were done on Macbook Pro running Chrome. Anyways, closing for now.

@samreid samreid closed this as completed Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants