Reputation: 363
I am doing some tuning in a very large application. Is there a way to measure number of events fired in an application? For example using something in System.Diagnostics?
Adding code inside events is NOT an acceptable solution due to the size of the application.
There are profiling tools, but the fast and simple approach for me would be something found in .Net
Upvotes: 3
Views: 190
Reputation: 161821
I'm not sure that knowing the number of events would help you in any way. It would be more helpful to know where your program is spending its time, or allocating its memory. A profiler will help with that.
For the record, a list of profilers:
Upvotes: 1
Reputation: 363
I have come to the conclusion to try performance measuremet tools instead. Since there is no easy way to do thye measurement code wise. I will tr ANTS to se what it can do for me.
Upvotes: 0
Reputation: 19765
Are you talking about Windows 'event viewer' or subscriptions to events on your classes?
if it's the latter, who subscribes to your events? Maybe you can write some 'glue' code that sites between the events and the subscribers counting away!
Upvotes: 0
Reputation: 882
This is a very interesting question.
There is really no easy way to trace events without any additional code. This doesn't mean that adding the code has to be hard or a performance hog.
If all your events use custom eventArgs you could add a simple logging statement to the constructor that would allow you to count every time that you create one of the custom eventArgs.
If you are not using custom eventArgs you could very easily extend eventArgs with a customEventArgs class that does exactly this counting. Just extend the constructor to update some static variable which you can write out to a log every so often. Then using a quick refactor you could rename all your default eventArgs to this new slightly different customEventArgs. This would take all of 10 minutes and would not break any existing code.
However, if you know that a profiler can do this, why not use it? If the application is this gigantic and you are trying to do very small optimizations whoever you are building this application for would probably not mind the added cost associated with you purchasing a license in exchange for the improvements to their software.
Upvotes: 0