简体   繁体   中英

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, just 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM