ASP.NET - How can I check how many milliseconds my codes takes to execute, using Visual Studio 2010
Is it possible to check how long a particular segment of code takes to execute, j开发者_StackOverflowust want to see if some loops etc. can be optimized better or use LinQ.
Is there such function built into Visual Studio or must I do this with some code, stopwatch class etc.?
Thanks.
var sw = Stopwatch.StartNew();
// you code.
sw.ElapsedMilliseconds;
Or you can use built in VS Profiler. You can find more on how to use VS profiler in Find Application Bottlenecks with Visual Studio Profiler
If you have VS2010 Ultimate:
From the Analyze
menu, select the Launch Performance Wizard
option.
Its been a while since I last used it, but I believe it tells you how long things take to execute and what's using up the most memory, and so on =)
Otherwise, you'll have to use the Stopwatch
class or a third party profiler.
Visual Studio Premium/Ultimate/Team versions come with a profiler. Otherwise you have to do your own profiling with the StopWatch
class.
精彩评论