Using the Stony Brook profiler

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.

Sampling

The debugger periodically interrupts your program execution andreads address where the program was executing and saves this

information. The rate at which the debugger samples your programcan be anywhere from 50 to 1000 times per second. Some machines may not be able tosupport 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.

Analyzing

The analyzer is accessed via the tools menu. If a sample datafile exists for the selected or default program then you can run the sample analyzeron the application. The analyzer shows the the results of the profile in multipleviews and formats to help you determine where is your program to look for possibleperformance improvements.