Prism 6.0 User's Guide

Using Timers

A high-quality timer called gethrtime is available on UltraSPARC-based systems. From C, your code can call it using:

#include 
hrtime_t gethrtime(void); 

This timer returns time in nanoseconds since some arbitrary point in the past (since system power-on). This time is well-defined for any node, but varies considerably from node to node. Consult the gethrtime man page for gethrtime for details. From Sun Fortran 77, you can write

INTEGER*8 GETHRTIME !$PRAGMA C(GETHRTIME)
DOUBLE PRECISION TSECONDS 
TSECONDS = 1.D-9 * GETHRTIME()

which converts nanoseconds to seconds.

The overhead and resolution for gethrtime from user code are usually better than one microsecond.