Next: , Previous: Qstl.h, Up: Interface


4.12 now.h: measuring time

The `now.h' file provides some simple time measurement routines. It is not included in `nana.h' so you must include this file separately.

It uses the `gettimeofday' system call and has an accuracy of between 1us and 10ms depending on the operating system and hardware configuration.

See the IPM package if you require better measurement tools.1

— Function: double now ()

Returns the time in seconds since the beginning of time as defined by your system. If you call `now_reset' the time will start again at 0.

— Function: double now_reset ()

Reset the times returned by `now' to 0.

— Function: double now_delta (double *dp)

Returns the elapsed time between *dp and now(). It then sets *dp to now, thus giving a delta time between particular events.

            t = now();
            for(;;) {
              ...; /* code that must finish in 50ms */
              I(now_delta(&t) <= 0.050);
            }
     

Footnotes

[1] In the fullness of time, we may integrate these routines in here.