请考虑以下用于测量Asp.Net应用程序中的请求/响应时间的代码:
protected void Application_EndRequest() { Trace.WriteLine(string.Format("{0}:{1}",(DateTime.Now - HttpContext.Current.Timestamp).TotalMilliseconds,HttpContext.Current.Request.RawUrl)); }
根据MSDN,DateTime.Now的近似分辨率为10毫秒.
此外,从MSDN HttpContext.Timestamp description开始,
The timestamp returned from the
Timestamp
property is the local time of the server and is set during the instantiation of theHttpContext
object. The local time is equal to the UTC time plus the UTC offset.
理论上,上面的代码应该以毫秒为单位给出总的请求/响应时间.
我的问题是,这将是多么准确?还有更准确/更好的方法吗?
解决方法
原文地址:https://www.jb51.cc/csharp/91388.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。