PAPI 7.1.0.0
Loading...
Searching...
No Matches
timer.h File Reference
Include dependency graph for timer.h:

Go to the source code of this file.

Functions

void StartTimer ()
 
double GetTimer ()
 

Variables

struct timeval timerStart
 

Function Documentation

◆ GetTimer()

double GetTimer ( )

Definition at line 56 of file timer.h.

57{
58#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
59 LARGE_INTEGER li;
60 QueryPerformanceCounter(&li);
61 return (double)(li.QuadPart-timerStart)/PCFreq;
62#else
63 struct timeval timerStop, timerElapsed;
64 gettimeofday(&timerStop, NULL);
65 timersub(&timerStop, &timerStart, &timerElapsed);
66 return timerElapsed.tv_sec*1000.0+timerElapsed.tv_usec/1000.0;
67#endif
68}
struct timeval timerStart
Definition: timer.h:34

◆ StartTimer()

void StartTimer ( )

Definition at line 37 of file timer.h.

38{
39#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
40 LARGE_INTEGER li;
41
42 if (!QueryPerformanceFrequency(&li))
43 {
44 printf("QueryPerformanceFrequency failed!\n");
45 }
46
47 PCFreq = (double)li.QuadPart/1000.0;
48 QueryPerformanceCounter(&li);
49 timerStart = li.QuadPart;
50#else
51 gettimeofday(&timerStart, NULL);
52#endif
53}

Variable Documentation

◆ timerStart

struct timeval timerStart

Definition at line 34 of file timer.h.