Kamenskyh
Kamenskyh

Reputation: 495

Where can I see Code execution time VS2019?

Where in the VS2019 can I see the execution time of the code? Sorry for stupid question

Upvotes: 8

Views: 32261

Answers (1)

rustyx
rustyx

Reputation: 85521

That depends on the precision you're interested in. If milliseconds then in Visual Studio 2019 you can see the time between two breakpoints under Diagnostic Tools -> Events -> Duration (opens automatically in Debug mode, or use Ctrl+Alt+F2).

VS2019 diagnostic tools events

Some notes:

  • Make sure to measure performance of the Release configuration. Debug build performance is meaningless.
  • Make sure the code under test is not optimized away.
  • If the code takes less than ~100ms to run, run it multiple times in a loop so that the measurement is on the order of 100ms or more, for better precision.
  • I don't know about C#. I assume VS offers similar features for C#.

For a higher precision C++ code performance is measured in code itself using e.g. the <chrono> package.

Upvotes: 18

Related Questions