C # Stopwatch when the async / wait method is inaccurate

I am writing some performance tests and want to be able to use a method that is asynchronous. The code looks like 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 and works fine, but the measured milliseconds are approximately 100 times higher than the query timings that we see in Fiddler-Fiddler, it reports 200-300 ms, but the stopwatch reports ~ 30 000 ms. Is there any catch about temporary asynchronous methods? Is the decision to make time in the action itself (which would be annoying?)

+4
source share
1 answer

, . , :

  • , Fiddler, , .
  • , , , . 30 , , , .
  • , .
+3

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


All Articles