Repository navigation
How to measure total request duration? #963
|
I'm looking for a way to measure total request duration. It'll be useful to create metrics. Do you have any idea how to do that? I know I can measure timestamps inside BeforeRequest/BeforeRespone handlers but do you know cleaner approach how to measure it? |
Answered by
justcoding121
Aug 3, 2026
Replies: 1 comment
|
Yep ? there's built-in timing for this now. Flip on 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 Closing this out ? shout if you need anything else. |
0 replies
Answer selected by
justcoding121
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yep ? there's built-in timing for this now. Flip on
EnableRequestTimingCaptureand reade.TiminginAfterResponse: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.