Sampling program execution

Profiling program execution is a two step process. First youmust sample the execution of the program, and then you analyze the sample results.The debugger is used to sample the program execution.

The debugger periodically interrupts your program execution andreads address where the program was executing and saves this information. That rateat which the debugger samples your program can be anywhere from 50 to 1000 timesper second. Some machines may not be able to support high sample rates.

For best results you should have no other programs running exceptthe debugger and the program you want to sample. Close any background tasks thatare running or may awaken at any point.

To sample the entire program execution:

While the above is suitable for applications like a compilerthat are 100% compute bound, most applications are not compute bound except for oneor two sections. In this case you would like to only sample during the executionof the compute bound code. Do this by setting a breakpoint at the start of the computeintensive code and a breakpoint and the end of this code. Then use the Run commandto execute to the first breakpoint. Now use the Run and Sample command to executeto the next breakpoint while sampling the code. Depending on how long this code executesand the sample rate chosen you may need to perform this sampling more than once toget a good amount of samples. You can sample multiple times and have the debuggerappend the new samples to the previously saved samples until you accumulate a goodsample set. You should make sure that your program executes exactly the same wayeach time you sample to provide the most consistent results.

The sampling options are in the debugger options dialog.