Hooking up .NET method for profiling purposes [duplicate]
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Profiling a method in C# to know how long does it take to run I need to check how long does it take to run a method. For example, I need to know how long does it take to run GetTypes() method in using System.Reflection in my project. foreach (Type t2 in a.GetTypes()) { Console.WriteLine(t2); } The easiest way might be running profiler or insert Stopwatch all the source files that uses GetTypes(), but I hope I