Detailed time information from HttpWebRequest

I am trying to extract detailed time information, like the Timing tab in Chrome, from an HTTP request made through HttpWebRequestin .NET:

enter image description here

Does anyone know if this is possible? I can not find any other documentation than to wrap the entire request in a stopwatch. But I really need details, for example, how much time is required to resolve the DNS, how much time is required to query, download content, etc.

+4
source share
4 answers

In the future, I will answer my question. Although the suggested answer with the registrar may work, I found a better (IMO) and much simpler approach:

var waiting = new Stopwatch();
var contentDownload = new Stopwatch();
waiting.Start();
using (var webResponse = (HttpWebResponse)webRequest.GetResponse())
{
    waiting.Stop();
    contentDownload.Start();
    using (var reader = new StreamReader(webResponse.GetResponseStream()))
    {
        var body = reader.ReadToEnd();
        contentDownload.Stop();
    }
}

, . GetResponse Chrome, GetResponseStream + ReadToEnd .

GET ( ). Request Sent , .

+3

, , , , , GlobalLog Logging. , , . , , .

+1

Miniprofiler https://miniprofiler.com/ Glimpse http://getglimpse.com/

Glimpse , HTTP, , -, SQL- .. , , , , Glimpse, .

0

, , HTTP- /

0

Source: https://habr.com/ru/post/1689367/


All Articles