asynchronous - C# Stopwatch to time an async/await method inaccurate -
i'm writing performance tests, , want able time method asynchronous. code looks this, action
func<task<httpresponsemessage>>
:
var sw = new stopwatch(); httpresponsemessage response = null; sw.start(); response = await action().configureawait(continueoncapturedcontext: false); sw.stop();
the code compiles , runs ok, measured milliseconds 100 times higher request timings see in fiddler - fiddler reports 200-300ms, stop watch reports ~30,000ms. there catch timing asynchronous methods? solution timing in action (which annoying?)
this should work fine measuring true amount of time takes asynchronous task finish. need keep in mind that:
- the time measuring fiddler measuring request only, , non of time takes code process response.
- there significant difference in time here , should able time code see how long takes progress break point before request after request. if closer 30 seconds stop watch accurate.
- there isn't obvious me make time inaccurate.
Comments
Post a Comment