Routines (alphabetical) > Routines: P > PROFILER

# PROFILER

The PROFILER procedure allows you to access 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.

## Example

; Be sure that the routines you want to profile are compiled.

void = CORRELATE(DIST(10), HANNING(10,10))

; Now include both user routines and system routines.

PROFILER

PROFILER, /SYSTEM

; Now perform the actual commands to profile.

for i=400,499 do c=CORRELATE(DIST(i), HANNING(i))

; Retrieve the profiling results.

PROFILER, /REPORT, /CODE_COVERAGE

IDL prints:

     Module   Type  Count    Only(s)   Avg.(s)     Time(s)   Avg.(s) LinesRun Total

     ABS       (S)   200    0.000582  0.000003    0.000582  0.000003      0      0

     CORRELATE (U)   100    0.004568  0.000046    0.006878  0.000069     27     49

     COS       (S)   100    0.001162  0.000012    0.001162  0.000012      0      0

     DIST      (U)   100    0.105290  0.001053    0.210409  0.002104     12     12

     FINDGEN   (S)   200    0.000659  0.000003    0.000659  0.000003      0      0

     FLOAT     (S)   200    0.000195  0.000001    0.000195  0.000001      0      0

     FLTARR    (S)   100    0.000675  0.000007    0.000675  0.000007      0      0

     HANNING   (U)   100    0.002771  0.000028    0.004873  0.000049     19     19

     MAX       (S)   100    0.000257  0.000003    0.000257  0.000003      0      0

     N_PARAMS  (S)   200    0.000098  0.000000    0.000098  0.000000      0      0

     ON_ERROR  (S)   300    0.000138  0.000000    0.000138  0.000000      0      0

     SQRT      (S) 22750    0.104195  0.000005    0.104195  0.000005      0      0

     TEMPORARY (S)   100    0.000065  0.000001    0.000065  0.000001      0      0

     TOTAL     (S)   500    0.001506  0.000003    0.001506  0.000003      0      0

## Syntax

PROFILER [, Module, /CLEAR, /CODE_COVERAGE, DATA=variable, FILENAME=path, OUTPUT=variable, /REPORT, /RESET, /SYSTEM

## Arguments

### Module

The program to which changes in profiling will be applied. If Module is not specified, profiling changes will be applied to all currently-compiled programs.

Note: The Module is often named with respect to the file in which it is stored. For example, the file `build_it.pro` may contain the module, `build_it`. If you specify the file name, you will incur a syntax error.

## Keywords

### CLEAR

Set this keyword to disable profiling of Module or of all compiled modules if Module is not specified. If the Module is a system routine then the SYSTEM keyword must also be set.

### CODE_COVERAGE

Set this keyword to output additional information on code coverage including the number of lines that were executed within the routine and the total number of lines.

Tip: You can use the CODE_COVERAGE routine to return detailed information on the line numbers that were executed.

### DATA

If the REPORT keyword is set, then set this keyword to a specified variable containing output of the report as an unnamed structure with the following tags and data types:

{NAME:char, COUNT:long, ONLY_TIME:double, TIME:double, SYSTEM:byte}

If CODE_COVERAGE is set then the structure will have the form:

{NAME:char, COUNT:long, ONLY_TIME:double, TIME:double,

SYSTEM:byte, LINES_RUN:long, LINES_TOTAL: long}

### FILENAME

If the REPORT keyword is set, then set this keyword to the name of a file in which to write the profile results.

### OUTPUT

If the REPORT keyword is set, then set this keyword to a specified variable in which to store the results of the REPORT keyword.

### REPORT

Set this keyword to report the results of profiling. If DATA or OUTPUT are present then the results are returned in the specified variables. Otherwise the results are output to the IDL output log.

### RESET

Set this keyword to reset the results of profiling. If this keyword is present then all other arguments and keywords are ignored.

### SYSTEM

Set this keyword to apply profiling changes to IDL system procedures and functions. By default, changes are only applied to user-written or library files.

Note: Using the profiler incurs a small overhead for each call to a routine. For routines which execute quickly, this overhead may be a significant fraction of the total execution time. Because of this, when you turn on profiling for all system routines, the following routines are not included: ARG_PRESENT, KEYWORD_SET, N_ELEMENTS, OBJ_ISA, OBJ_VALID, PTR_VALID, and SIZE. You can manually turn on profiling for these routines using the Module argument.

## Version History

5.1 | Introduced
7.0 | Added FILENAME keyword
8.4 | Added CODE_COVERAGE keyword

## See Also

CODE_COVERAGE, SYSTIME, TIC, TOC