Skip to content
Discussion options

You must be logged in to vote

Yep ? there's built-in timing for this now. Flip on EnableRequestTimingCapture and read e.Timing in AfterResponse:

proxyServer.EnableRequestTimingCapture = true;

proxyServer.AfterResponse += async (sender, e) =>
{
    var timing = e.Timing;
    if (timing == null) return;

    Console.WriteLine($"{e.HttpClient.Request.Url} took {timing.TotalDuration.TotalMilliseconds:F0}ms " +
                      $"(TTFB {timing.TimeToFirstByte?.TotalMilliseconds:F0}ms)");
};

You also get breakdowns like TimeToFirstByte, ConnectionWaitDuration, ResponseDeliveryDuration, etc. No need to roll your own timestamps in BeforeRequest/BeforeResponse.

Closing this out ? shout if you need anything else.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by justcoding121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants