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 IDLDE or by entering PROFILER at the Command Input Line. For more information about the PROFILER procedure, see PROFILER.
Select "Profile" from the Run menu. The Profile dialog appears.
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.
Select this checkbox to select all the user modules for profiling.
This field includes all IDL system procedures and functions.
Select this checkbox to select all the system modules for profiling.
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.
Click "Report" from the Profile dialog in the Run menu of the IDLDE. The Profile Report dialog appears.
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.
The name of the library, user, or system procedure or function.
The type of module. System procedures or functions are associated with an "S". User or library functions or procedures are associated with a "U".
The number of times the procedure or function has been called.
The time required, in seconds, for IDL to execute the given function or procedure, not including any calls to other functions or procedures (children).
Average of the Only(sec) field above.
The time required, in seconds, for IDL to execute the given function or procedure including any calls to other functions or procedures.
Average of the +Children(sec) field above.
Click "Print" to print the report. The Print dialog appears. You can also select "Print" from the File menu of the IDLDE. 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.
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)) b=a 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.
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 Input 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 Input 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 Input Line; the already-compiled library function is executed again, making it available for profiling.