TOC
The TIC and TOC routines work together to allow you to check the running time of your IDL programs. The TIC routine stores the initial system time. TOC records the final system time, then calculates and displays the total elapsed time (final time - system time).
You may call the TIC routine as either a procedure or a function. When you call TOC as a procedure, the routine prints out the elapsed time between the calls. When you call TOC as a function, the routine returns the elapsed time without printing.
Example
Use the profiler with TIC and TOC:
; Reset any previous profiling and enable
TIC, /PROFILER
clock = TIC()
WAIT, 1
; Get a report but continue profiling since we had a ClockID
TOC, clock, REPORT=interimReport
PRINT, interimReport[-1]
WAIT, 1
; No ClockID, so stop profiling and retrieve the final report
TOC, REPORT=finalReport
PRINT, finalReport[-1]
IDL prints:
% Time elapsed: 1.0009999 seconds.
{ WAIT 1 0.99925080 0.99925080 1}
% Time elapsed: 2.0040002 seconds.
{ WAIT 2 1.9988044 1.9988044 1}
See the TIC routine for more examples.
Tip: If you call TIC with the PROFILER keyword and you are using the IDL Workbench, IDL will automatically refresh the Profiler view when TOC is called.
Syntax
TOC [, ClockID] [, LUN=lun] [, REPORT=variable]
or
Result = TOC( [ClockID] [, REPORT=variable] )
Return Value
If you call TOC as a function, then IDL returns the elapsed time without printing.
Arguments
ClockID
Set this optional argument to a scalar or array of clock identifiers from earlier calls to the TIC function. IDL will computer the elapsed time for these particular clocks instead of computing the total elapsed time.
Note: If profiling was enabled in an earlier call to TIC, calling TOC with ClockID will not disable profiling. To disable profiling you need to call TOC with no arguments. This allows you to turn on profiling for an entire block of code, and then measure elapsed times for subroutines within that code.
Keywords
LUN
If this keyword is set to an open file unit number, then IDL will redirect all TOC output to that file instead of to the output console. The LUN keyword is only available when calling TOC as a procedure.
REPORT
If profiling was enabled in an earlier call to TIC (using the PROFILER keyword), then set this keyword to a named variable in which to return the profiling results. IDL returns the profiling results as a structure array with the following fields:
{NAME:char, COUNT:long, ONLY_TIME:double, TIME:double, SYSTEM:byte}
See the PROFILER routine for details on these fields.
Note: Using the REPORT keyword does not disable profiling or reset the profiling results. To disable profiling, call TOC with no arguments. To reset profiling results, either call TIC with /PROFILER (which also restarts the profiler) or call PROFILER, /RESET.
Version History
8.2.2 | Introduced |
8.3 | Added LUN keyword |