Introduction to Profiling in Rider
Let's run a first profiling session on a Sudoku solver sample application.
Sudoku Solver
In this tutorial, you will make use of a Sudoku solver application. It reads a Sudoku puzzle from a text file, and then tries to solve it using a brute-force approach.
Internally, it iterates over every cell of a puzzle board, tries all combinations, and then verifies the solution.
0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 3, 0, 8, 5
8, 0, 1, 0, 2, 0, 0, 0, 0
0, 0, 0, 5, 0, 7, 0, 0, 0
0, 0, 4, 0, 0, 0, 1, 0, 0
0, 9, 0, 0, 0, 0, 0, 0, 0
5, 0, 0, 0, 0, 0, 0, 7, 2
0, 0, 2, 0, 1, 0, 0, 0, 0
0, 0, 0, 0, 4, 0, 0, 0, 1
A simple puzzle is solved in less than a second, more complex ones can take 10 to 20 seconds. In this tutorial, you will see if this can be optimized, and how.
Profiling in Rider
Rider integrates with the dotTrace profiler to provide performance profiling of .NET applications. A profiling session can be started from the toolbar, or from the Run menu.
The profiling modes available depend on your operating system, and the .NET Framework version used in your application. A compatibility matrix is available in the web help.
Once the profiling is started, you will see the Performance Profiler tool window open. It shows the profiling controller, where you can get a snapshot, detach from the running application, and more. For the Sudoku solver, a snapshot is captured automatically after the application exits.
A profiling snapshot gives you the information required to start optimizing your application. It shows the call tree of method calls on all threads, and the top methods with the highest execution time.
In the next step, you will see the different profiling modes that are available.