second(3F)
SECOND - Returns elapsed CPU time
As shipped in IRIX 6.5. First release of IRIX 6.5.
NAME SECOND - Returns elapsed CPU time SYNOPSIS All systems: second=SECOND() UNICOS systems: CALL SECOND(second) IMPLEMENTATION UNICOS, UNICOS/mk and IRIX systems DESCRIPTION SECOND returns the elapsed user CPU time as a real number in seconds (a default REAL*4) since the start of a program, including time accumulated by all processes in a multitasking program. SECOND returns execution time only for the current program. For example, a script runs a 50-second program 10 times. A SECOND call at the end of the 10th run (or 1st or 3rd or 7th) returns 50 seconds. On UNICOS systems, SECOND is not appropriate for timing small timed regions. If the timed region is fewer than 4000 clock periods (CPs) in duration, the variation in the accuracy of SECOND can be 10% or more on one processor. On multiple processors, the variation can be on the order of 10,000 to 400,000 CPs. The second argument is the result, or CPU time (in type real seconds) accumulated by all processes in a program. NOTES On UNICOS systems, the initial call to SECOND may take longer than subsequent calls due to certain initializations performed by the routine. If the cost of calling SECOND is important, ignore the initial call when computing SECOND's time. The calculation of OVERHEAD in the second example, following, serves this purpose. On UNICOS systems, the CPU times gathered by SECOND include wait-semaphore time. WARNINGS If you are trying to time your entire program, and you are using Autotasking, the CPU time returned by SECOND may not reflect all of the CPU time used by your program. This is due to the fact that slave CPUs may be still active when your program terminates (for instance, with a STOP or END statement). Depending on the number of active CPUs on your machine, the extra time needed to terminate the slaves may be substantial compared with your program time. Thus, if you use SECOND to time your program, and you are also using time(1) or ja(1), the time reported by these other utilities could be much higher than that reported by SECOND. Because of the large variation on multiple processors, SECOND should be used cautiously in multitasked routines. On IRIX systems, the presence of multitasking does not affect the accuracy of SECOND. EXAMPLES Example 1: This example calculates the CPU time used in DOWORK: BEFORE = SECOND( ) CALL DOWORK( ) AFTER = SECOND( ) CPUTIME = AFTER - BEFORE Example 2: If the CPU time is small enough that the overhead for calling SECOND may be significant, the following example is more accurate: T0 = SECOND( ) OVERHEAD = SECOND( ) - T0 BEFORE = SECOND( ) CALL DOWORK( ) AFTER = SECOND( ) CPUTIME = (AFTER - BEFORE) - OVERHEAD SEE ALSO RTC(3I), SECONDR(3F), TIMEF(3F), TSECND(3F) ja(1), time(1) in the UNICOS User Commands Reference Manual, publication SR-2011 Application Programmer's Library Reference Manual, publication SR-2165, for the printed version of this man page.