本文介绍了使用HTTPWebRequest检查响应时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试查找某些代理的性能.我在.net中尝试了Ping
类,但它不接受端口.有没有办法检查httpwebrequest
响应花费了多长时间?
I'm trying to find the performance of some of my proxies. I tried the Ping
class in .net but it does not accept ports. Is there a way to check how long a response took with httpwebrequest
?
推荐答案
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(myUri);
System.Diagnostics.Stopwatch timer = new Stopwatch();
timer.Start();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
response.Close ();
timer.Stop();
TimeSpan timeTaken = timer.Elapsed;
这篇关于使用HTTPWebRequest检查响应时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!