Using Visual Studio Profiler

Sometimes code runs too slowly. Profiling is the process of determining which parts of your code are taking the most time, so you can spend your time optimizing the right things.

To user the profiler, first switch your code from Debug to Release build. Make sure your code builds and runs correctly without the profiler. Then click on the "Debug" menu, "Performance Profiler" option. There are several different items that could be measured. Usually you'll want to check "CPU Usage" and uncheck the others. Click on "Start." Your program runs as it ususally does. Quit your program as soon as it finishes the time consuming part. The Visual Studio Profiler displays your top 5 functions that took the most time. Other information is also available.