同时检查多个 URL 的页面加载时间
如果 URL 作为输入给出,谁能指导我应该编写哪些 C# 代码来获取每个 URL 的页面加载时间?
或者
如果可能的话,请向我提供任何可以执行此操作的软件的链接。任何以多个 URL 作为输入并提供每个 URL 的页面加载时间的软件。
Can anyone guide me what C# code should I write for getting page load time of each URL if the URLs are given as an input ?
OR
if possible please provide me link to any software that does that. Any software that takes several URL as input and provides the page load time for each URL.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我用它来保持内部网站活跃并测量/记录响应时间,这是一种保持活动的服务:
ErrorLogger
是我围绕Log4Net
制作的一个小包装器。I am using this to keep internal web sites active and measure/log response time, kind of a keep alive service:
ErrorLogger
is a little wrapper I made aroundLog4Net
.您需要一个
Stopwatch
,以及一个WebClient
或WebRequest
。You'll want a
Stopwatch
, and either aWebClient
or aWebRequest
.我相信您熟悉 Web 调试代理 Fiddler。 Fiddler 中有很多内容是您的应用程序不需要的(例如 UI),但是它们提供了一个可以包含在您的项目中的 .NET 库,该库将为您提供您可能想要的所有 HTTPness。
下载中包含一个示例应用程序,我在几分钟内修改了它,您可以通过它访问统计选项卡下的 fiddler UI 中显示的相同信息。检查 fiddlercore dll 中的 Session.Timers 对象是否有这些值。
客户端连接:15:03:05.017
客户端开始请求:15:03:05.056
客户端完成请求:15:03:05.076
确定网关:0ms
DNS 查找:3 毫秒
TCP/IP 连接:20ms
HTTPS 握手:0 毫秒
服务器已连接:15:03:05.151
FiddlerBeginRequest:15:03:05.152
服务器得到请求:15:03:05.157
服务器开始响应:15:03:05.292
服务器完成响应:15:03:05.314
客户端开始响应:15:03:05.331
客户端完成响应:15:03:05.333
总体已用时间:00:00:00.2770277
希望这会有所帮助,您需要弄清楚如何创建自己的会话而不是使用代理,但这是产品的既定功能,不需要太多时间。
I'm sure your familiar with the Web debugging proxy Fiddler. There is a lot in Fiddler that you will not need (like a UI) for your application, however they provide a .NET library that can be included in your project that will give you all the HTTPness that you could ever want.
There is a sample app included in the download that I modified in a few minutes that will give you access to the same information shown in the fiddler UI under the statistics tab. Check Session.Timers object in the fiddlercore dll for these values.
ClientConnected: 15:03:05.017
ClientBeginRequest: 15:03:05.056
ClientDoneRequest: 15:03:05.076
Determine Gateway: 0ms
DNS Lookup: 3ms
TCP/IP Connect: 20ms
HTTPS Handshake: 0ms
ServerConnected: 15:03:05.151
FiddlerBeginRequest: 15:03:05.152
ServerGotRequest: 15:03:05.157
ServerBeginResponse: 15:03:05.292
ServerDoneResponse: 15:03:05.314
ClientBeginResponse: 15:03:05.331
ClientDoneResponse: 15:03:05.333
Overall Elapsed: 00:00:00.2770277
Hope this helps, you will need to figure out how to create your own session instead of using the proxy but that is a stated feature of the product and should not require much time.
我推荐YSlow,是检查网站性能非常有用的工具,YSlow
I recommend YSlow ,is very useful tools for checking website performance ,YSlow
试试这个
有了这个我得到
Try this
With this I get
如果我正确理解了这个问题,那么 Apache JMeter 可以这样做: http://jmeter.apache.org/
它是可编写脚本的,您可以设置各种负载测试场景。
If I am understanding the question correctly, then Apache JMeter could do this: http://jmeter.apache.org/
It is scriptable, and you can set up a variety of scenarios for load testing.
您是否想要测量响应第一个请求所需的时间,或者是否想要包括样式和外部脚本的下载以及客户端渲染?
第一个可以简单地通过使用 网络客户端。
对于后者,请在一个表单,您可以在其中创建使用 DocumentCompleted 事件:
Do you want to measure the time it takes for the first request to be answered, or do you want to include the downloading of style and external scripts and clientside rendering?
The first can simply be solved by using a WebClient.
While for the latter, put a WebBrowser on a form where you create a method for consuming the DocumentCompleted event: