Forum Visual Studio

Time Profiler

Hi there, I'm experimenting with the profiler for the very first time.
I got useful information about allocations but I cannot figure out how to use the time profiler in the right way.
I keep getting very different time for my method execution from what I can see with a simple watch/chrono in code than what I can see with the profiler.
Not light difference. I have some rest call that takes around a second and I see in the profiler 43ms.
Is there a guide/tutorial? Do you have some suggestion?
Thankyou!

Posts

  • MicheleTameniMicheleTameni USMember

    Nobody is using the time profiler and has some suggestion?

  • JohnHardmanJohnHardman GBUniversity mod

    @MicheleTameni said:
    Not light difference. I have some rest call that takes around a second and I see in the profiler 43ms.
    Is there a guide/tutorial? Do you have some suggestion?

    I would assume that the 43ms is the time spent executing code in your method (i.e. when the Instruction Pointer is within your method), whereas the "around a second" is the elapsed time for your method to complete. The significant different results from use of async and await. When your method cannot continue execution until network I/O (the REST operations) completes, the use of await means that execution continues outside your method. The time profiler will be using statistical sampling to see where the Instruction Pointer is at any time. As the Instruction Pointer will be outside your method until the REST operations complete, the time profiler does not consider the "wait" time as being part of your method. Hence, it might be a second before a REST operation completes, but for most of that time code will have been executing that is not within your method.

  • JohnHardmanJohnHardman GBUniversity mod

    @MicheleTameni - Did that answer your question? If so, don't forget to Like and/or mark the post as Accepted Answer.

Sign In or Register to comment.