开发者

How can I track the time it takes a block of my MVC3 code to execute?

开发者 https://www.devze.com 2023-03-15 07:15 出处:网络
My MVC3 application is not running as fast as I hoped. I\'d like to find out if s开发者_运维百科ome of the database look ups are taking too long. Is there a way that I can time part of a block of code

My MVC3 application is not running as fast as I hoped. I'd like to find out if s开发者_运维百科ome of the database look ups are taking too long. Is there a way that I can time part of a block of code within a controller. For example:

var a = the_time_now;
...
...
var b = the_time_now;

<log the code area name and time b - time a 

I am fairly new to MVC and would appreciate any advice. Note that I currently have no uses on my system so if I was logging the time then it would not load things down too much :-)


Use the Stopwatch class for the code execution time tracking. this is not titly bound to MVC, this is used generally in .net Framework

0

精彩评论

暂无评论...
验证码 换一张
取 消