ASP.net - 如何区分页面处理时间和客户端传输时间

发布于 2024-07-06 00:36:01 字数 361 浏览 14 评论 0原文

博客中的单个计时栏自然包括客户端传输计时。 对于分析,我想将构建时间过长的页面与客户端速度较慢的请求区分开来。

对于缓冲页面,我查看了 ASP.NET 页面生命周期模型,但没有看到可以在哪里利用并以代码方式测量页面刷新到客户端之前的页面处理时间。

我可能应该提到我的目标是生产监控(而不是测试或开发)。 此外,目的是用此测量值对博客进行注释,以供以后分析。 目前,我们使用 Response.AppendToLog() 自由地注释博客。 我相信使用 Response.AppendToLog() 的愿望在某种程度上限制了我潜在的日志点,例如,响应对象在 Application_EndRequest 中不可行。

任何见解将不胜感激。

The single timing column in the weblog naturally includes client transmission timing. For anamoly analysis, I want to differentiate pages that took excessive construction time from requests that simply had a slow client.

For buffered pages, I've looked at the ASP.NET page lifecycle model and do not see where I can tap in and codewise measure just the page-processing time before the page is flushed to the client.

I probably should have mentioned that my goal is production monitoring (not test or dev). In addition, the intent is to annotate the weblogs with this measurement for later analysis. Current we liberally annotate the weblogs with Response.AppendToLog(). I believe the desire to use Response.AppendToLog() somewhat limits my potential logpoints as for instance, the response-object is not viable in Application_EndRequest.

Any insight would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

友谊不毕业 2024-07-13 00:36:01

您可以在 BeginRequest 和 PreSendRequestContent 中使用秒表,如其他两个答案中所述,或者您可以仅在 PreSendRequestContent 中使用请求的时间戳。

例如,在 SingingEels 上,我将其添加到我的母版页的底部(是的,这是一个黑客) : <%=DateTime.Now.Subtract(HttpContext.Current.Timestamp).TotalSeconds %>

这样我就可以看到任何页面在服务器上实际执行所需的时间,包括访问数据库, ETC。

You could use a Stopwatch in the BeginRequest and the PreSendRequestContent as mentioned in the other two answers, or you could just use the request's Timestamp in the PreSendRequestContent.

For example, on SingingEels, I added this to the bottom of my Master Page (yes, it's a hack) : <%=DateTime.Now.Subtract(HttpContext.Current.Timestamp).TotalSeconds %>

That way I can see how long any page took to actually execute on the server, including hitting the database, etc.

抚笙 2024-07-13 00:36:01

最简单的方法可能是在 global.asax 文件中使用以下事件:

protected void Application_BeginRequest(Object sender, EventArgs e)
protected void Application_EndRequest(Object sender, EventArgs e)

您还可以实现自定义 httpmodule

the easist way would probably be to use the follow events in the global.asax file:

protected void Application_BeginRequest(Object sender, EventArgs e)
protected void Application_EndRequest(Object sender, EventArgs e)

You could also implement a custom httpmodule

过潦 2024-07-13 00:36:01

如果您想登录特定页面,我相信 asp.net 页面的生命周期以 PreInit 开始并以 Dispose 结束,因此您可以在这些事件中记录您想要的任何内容。

或者,如果您想登录每个页面,正如 Bob Dizzle 指出的那样,您可以使用 Global.asax 文件,该文件有一千个事件可供选择:http://msdn.microsoft.com/en-us/library/2027ewzw.aspx

If you want to log on a specific page, I believe asp.net pages' lifecycle begin with PreInit and end with Disposed, so you can log anything you want in those events.

Or, if you want to log on every page, as Bob Dizzle pointed out, you can use the Global.asax file, which has a thousand events to choose from : http://msdn.microsoft.com/en-us/library/2027ewzw.aspx

や三分注定 2024-07-13 00:36:01

您还可以在 Web 服务器上进行测试。 然后 ClientTransmission 时间实际上变为 0。

You could also do your testing right there on the web server. Then ClientTransmission time becomes effectively 0.

夏夜暖风 2024-07-13 00:36:01

这取决于您拥有的性能工具的功能集。 但如果您只需要记录处理时间,那么您可以采用这种方法。

  1. HttpApplication.BeginRequest 事件。
  2. HttpApplication.PreSendRequestContent 事件。

如果您只想要特定页面,那么您可以在 BeginRequest 事件中检查这一点。
应用程序事件可以附加在 Global.asax 中。

This depends on the feature set of the performance tools you have. But if you just need to log the processing time then you could follow this approach.

  1. Log the starting time in the HttpApplication.BeginRequest event.
  2. Log the elapsed time in the HttpApplication.PreSendRequestContent event.

If you just want a specific page then you could check for this in the BeginRequest event.
The application events can be attached in Global.asax.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文