C# 2.0 Execution Time Timer
c#, execution-time, performance, stopwatch, timer
Solution
I think u must try the PostSharp way http://www.postsharp.org/
Changing the code in the sample for this one:
public class ProfileMethodsAttribute : OnMethodBoundaryAspect
{
public override void OnEntry( MethodExecutionEventArgs eventArgs)
{ eventArgs.MethodExecutionTag = Stopwatch.StartNew(); }
public override void OnExit( MethodExecutionEventArgs eventArgs)
{
// Here u can get the time
Console.WriteLine(((Stopwatch)eventArgs.MethodExecutionTag).ElapsedMilliseconds);
}
}
You can get the time off any method
Problem
I would like to be able to calculate the amount of time a number of functions take to execute. I was thinking about using some type of stopwatch class. I can call start/stop before and after each function call, however that seems horribly ugly to me. Is there a way to do this without a stopwatch class? Can something in the Reflections class help with this? Thanks in advance for you input.