Is there an C# attribute (for method) to calculate the time of execution of this method? Is there another way?
You can use Aspect Oriented programming to do this. Look at this example from PostSharp: http://www.sharpcrafters.com/solutions/performance
The trick here is to define behavior that will be injected into your code at compile time. One use case is to add timing to methods like you need.
there is other way: you could use VS Profiler to check how many times and how long particuler method is executed.
or you could 3rd party library which uses Attributes for profiling the performance, see this related topic What Are Some Good .NET Profilers?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With