我有一个简单的Web API,返回联系人列表:
public class ContactsApi : ApiController
{
public List<Contact> GetContacts()
{
Stopwatch watch = new Stopwatch();
watch.Start();
// Doing some business to get contacts;
watch.Stop();
// The operation only takes less than 500 milliseconds
// returning list of contacts
}
}
我使用Stopwatch
测试数据检索性能时,显然只需不到一秒钟。但是,当我通过Chrome浏览器向GetContacts
操作发出请求时,需要4到5秒才能返回数据。
显然这种延迟与我的数据检索代码无关。对我来说,Web API运行缓慢。但是我不知道如何调试和跟踪它。
是否有任何实用工具可以记录ASP.NET HTTP请求处理管道的时间?我的意思是,类似于导航计时,显示每个事件发生的时间?