Defines | Functions | Variables

High Resolution (micro-second) Timing Module

Timing functions for high resolution (micro-second) timing that can be used within any C code. The performence is OS dependent and only supports Windows and POSIX/Linux. More...

Defines

#define START_TIMER   ( clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &startTime) )
 < Start Timer Macro (Linux)
#define RESTART_TIMER   ( clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &startTime) )
 Stop Timer Macro (Linux).
#define STOP_TIMER   ( clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &stopTime) )
 Time elapsed so far, return timespec struct (Linux).
#define TIME_ELAPSED   ( diff_times(startTime, stopTime) )
 Returns seconds elapsed (Linux).
#define SECONDS_ELAPSED   ( diff_times(startTime, stopTime).tv_sec )
 Return nano-seconds elapsed, use with SECONDS_ELAPSED to get total time (Linux).
#define NANOSECONDS_ELAPSED   ( diff_times(startTime, stopTime).tv_nsec )
 Returns time in milli-seconds (Linux).
#define MILLISECONDS_ELAPSED   ( diff_times(startTime, stopTime).tv_sec*1000ULL + diff_times(startTime, stopTime).tv_nsec/1000000ULL )
 Returns time in micro-seconds (Linux).
#define MICROSECONDS_ELAPSED   ( diff_times(startTime, stopTime).tv_sec*1000000ULL + diff_times(startTime, stopTime).tv_nsec/1000ULL )

Functions

NTTW_DLL_SYM struct timespec diff_times (const struct timespec start, const struct timespec end)

Variables

static struct timespec startTime
 Start Time Global Variable (Linux).
static struct timespec stopTime
 Start Time Global Variable (Linux).

Detailed Description

Timing functions for high resolution (micro-second) timing that can be used within any C code. The performence is OS dependent and only supports Windows and POSIX/Linux.

The main functions are START_TIMER, STOP_TIMER and MICROSECONDS_ELAPSED. These commands require semi-colons at the end if used on its own.


Define Documentation

#define MICROSECONDS_ELAPSED   ( diff_times(startTime, stopTime).tv_sec*1000000ULL + diff_times(startTime, stopTime).tv_nsec/1000ULL )

Definition at line 131 of file timing.h.

#define MILLISECONDS_ELAPSED   ( diff_times(startTime, stopTime).tv_sec*1000ULL + diff_times(startTime, stopTime).tv_nsec/1000000ULL )

Returns time in micro-seconds (Linux).

Definition at line 127 of file timing.h.

#define NANOSECONDS_ELAPSED   ( diff_times(startTime, stopTime).tv_nsec )

Returns time in milli-seconds (Linux).

Definition at line 123 of file timing.h.

#define RESTART_TIMER   ( clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &startTime) )

Stop Timer Macro (Linux).

Definition at line 107 of file timing.h.

#define SECONDS_ELAPSED   ( diff_times(startTime, stopTime).tv_sec )

Return nano-seconds elapsed, use with SECONDS_ELAPSED to get total time (Linux).

Definition at line 119 of file timing.h.

#define START_TIMER   ( clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &startTime) )

< Start Timer Macro (Linux)

Restart Timer Macro (Linux)

Definition at line 103 of file timing.h.

#define STOP_TIMER   ( clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &stopTime) )

Time elapsed so far, return timespec struct (Linux).

Definition at line 111 of file timing.h.

#define TIME_ELAPSED   ( diff_times(startTime, stopTime) )

Returns seconds elapsed (Linux).

Definition at line 115 of file timing.h.


Function Documentation

diff_times ( const struct timespec  start,
const struct timespec  end 
) [read]

Finds the difference in times. For POSIX/Linux only.

Definition at line 43 of file timing.c.


Variable Documentation

struct timespec startTime [static]

Start Time Global Variable (Linux).

Definition at line 92 of file timing.h.

struct timespec stopTime [static]

Start Time Global Variable (Linux).

Definition at line 93 of file timing.h.