1
//========================================================================
5
// This file is licensed under GPLv2 or later
7
// Copyright 2005 Jonathan Blandford <jrb@redhat.com>
8
// Copyright 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
9
// Copyright 2010 Hib Eris <hib@hiberis.nl>
10
// Inspired by gtimer.c in glib, which is Copyright 2000 by the GLib Team
12
//========================================================================
16
#ifdef USE_GCC_PRAGMAS
17
#pragma implementation
23
#define USEC_PER_SEC 1000000
25
//------------------------------------------------------------------------
27
//------------------------------------------------------------------------
29
GooTimer::GooTimer() {
33
void GooTimer::start() {
34
#ifdef HAVE_GETTIMEOFDAY
35
gettimeofday(&start_time, NULL);
37
QueryPerformanceCounter(&start_time);
42
void GooTimer::stop() {
43
#ifdef HAVE_GETTIMEOFDAY
44
gettimeofday(&end_time, NULL);
46
QueryPerformanceCounter(&end_time);
51
#ifdef HAVE_GETTIMEOFDAY
52
double GooTimer::getElapsed()
55
struct timeval elapsed;
58
gettimeofday(&end_time, NULL);
60
if (start_time.tv_usec > end_time.tv_usec) {
61
end_time.tv_usec += USEC_PER_SEC;
65
elapsed.tv_usec = end_time.tv_usec - start_time.tv_usec;
66
elapsed.tv_sec = end_time.tv_sec - start_time.tv_sec;
68
total = elapsed.tv_sec + ((double) elapsed.tv_usec / 1e6);
75
double GooTimer::getElapsed()
79
QueryPerformanceFrequency(&freq);
82
QueryPerformanceCounter(&end_time);
84
time_in_secs = (double)(end_time.QuadPart-start_time.QuadPart)/(double)freq.QuadPart;
85
return time_in_secs * 1000.0;
89
double GooTimer::getElapsed()
91
#warning "no support for GooTimer"