Answer the question
In order to leave comments, you need to log in
NancyFx how to find out the execution time of an asynchronous request?
I have requests processed asynchronously, I need to know the execution time of each request in order to control the load on the server.
PS. I know about stopwatch, all trash synchronize it. NancyFx has Before(before request execution), After(after request execution) pipline's. Here it is in the framework and these modules that matter ...
Answer the question
In order to leave comments, you need to log in
As usual, we detect the moment when the request processing starts and ends on the server side, we calculate the difference:
var sw = new Stopwatch();
sw.Start();
await MySuperCoolJobAsync();
sw.Stop();
Trace.WriteLine($"{sw.ElapsedMilliseconds} мс");
Actually, regardless of the specific implementation, you need to "detect" the start time and end time of the task, look at their difference.
Depending on what time you need (including transport to the server or without it), both the calling component and the task itself can detect.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question