The IDL Code Profiler
The IDL Code Profiler helps you analyze the performance of your applications. You can easily monitor the calling frequency and execution time for procedures and functions. The Profiler can be used with programs entered from the command line as well as programs run from within a file.
You can start the IDL Code Profiler by selecting "Profile" from the Run menu of the IDL Workbench or by entering PROFILER at the Command Line. For more information about the PROFILER procedure, see "PROFILER" (IDL Reference Guide).
Note
Calling the Profiler from the Command Line does not start the Profiler dialog.
The Profile Dialog
Select "Profile" from the Run menu. The Profile dialog appears.
User Modules
User modules include user-written procedures as well as library procedures and functions provided with IDL. By default, none of the User Modules are selected for profiling. To select a module, click on the checkbox next to it. All user modules must be compiled before opening the Profile dialog in order to be available for profiling.
All User Modules
Select this checkbox to select all the user modules for profiling.
System Modules
This field includes all IDL system procedures and functions.
All System Modules
Select this checkbox to select all the system modules for profiling.
Buttons
Click "Profile All" to enable profiling for all the available modules—System and User. Click "Clear All" to disable profiling for all the available modules—System and User. Click "Reset" to clear the report shown in the "Profile Report" dialog. The "Profile Report" dialog is dismissed, as it no longer contains any information. Click "Report" to generate a profile of the selected modules. The Profile Report dialog appears. Click "Cancel" to dismiss the Profile dialog. Click "Help" to display Help on this dialog.
The Profile Report Dialog
Click "Report" from the Profile dialog in the Run menu of the IDL Workbench. The Profile Report dialog appears.
Fields in the Profiler Report Dialog
The fields in the Profiler Report dialog show the following attributes of the modules selected for profiling from the Profile dialog. You can sort the values in each column in both ascending and descending order by clicking anywhere within the column. By default, the Modules column is sorted alphabetically.
Note
Whether you enter a program at the command line or run a program contained in a file, the PROFILER procedure reports the status of all the modules compiled and executed either since profiling was first set or since the PROFILER was reset.
Modules
The name of the library, user, or system procedure or function.
Typ
The type of module. System procedures or functions are associated with an "S". User or library functions or procedures are associated with a "U".
Count
The number of times the procedure or function has been called.
Only(sec)
The time required, in seconds, for IDL to execute the given function or procedure, not including any calls to other functions or procedures (children).
Only Avg
Average of the Only(sec) field above.
+Children(sec)
The time required, in seconds, for IDL to execute the given function or procedure including any calls to other functions or procedures.
+Child Avg
Average of the +Children(sec) field above.
Buttons
Click "Print" to print the report. The Print dialog appears. You can also select "Print" from the File menu of the IDL Workbench. Click "Save" to save the report as a text file. The Save Profile Report dialog appears. Click "Cancel" to dismiss the Profile Report dialog. The contents remain available after cancelling. Click "Help" to display Help on this dialog.
Using the IDL Code Profiler
Open a new editor file by selecting "New" from the File menu.
Enter the following lines in the editor:
PRO prof_test OPENR, 1, FILEPATH('nyny.dat', SUBDIR=['examples', 'data']) a=ASSOC(1, BYTARR(768,512, /NOZERO)) b=a[0] CLOSE, 1 TV, b END
Save the file as prof_test.pro by selecting "Save" from the File menu. The Save As dialog appears.
To use the IDL Code Profiler, you must first compile the routines you would like to profile. For more involved programs, you can use RESOLVE_ALL to compile all uncompiled functions or procedures that are called in any already-compiled procedure or function.
Select "Profile..." from the Run menu. The Profile dialog appears; it will remain visible until dismissed. Select "Profile All" to profile all the available modules.
Run the application by selecting "Run" from the File menu. After the application is finished, return to the Profile dialog and click "Report". The Profile Report dialog appears, as shown in the following figure.
For more information about the capabilities of either dialog, see The Profile Dialog and The Profile Report Dialog.
Profiling with Command Line Modules
We will demonstrate how the Profiler handles newly compiled modules. The above example set profiling for all system files, plus the user module, prof_test, and the library function, FILEPATH. If you have altered the above results, reset the report and run prof_test again.
Enter the following lines at the Command Line:
;Create a dataset using the library function DIST. Note that DIST ;is immediately compiled. A= DIST(500) ;Display the image. TV, A
Return to the Profile dialog. You will note that the DIST function has been appended to the User Module field, but that it remains deselected. The Profiler will not include any uncompiled modules by default. Click "Report" in the Profile dialog to refresh the Profile Report dialog's results. The following figure shows the new results. Note that TV is counted twice, and that more system modules have been appended to the Modules column. The DIST function, although it is not itself included, calls system routines which were previously selected for profiling.
If you select DIST in the User Modules field in the Profile dialog and then re-enter only the statement calling TV at the Command Line, you will notice that only the count for TV increases in the profiler report. You must re-enter the statement calling DIST at the Command Line; the already-compiled library function is executed again, making it available for profiling.


