1
static const char rcsid[] = "$Id: Clock.cpp,v 1.9 2002/09/15 22:40:50 bastiaan Exp $";
4
* See the COPYING file for the terms of usage and distribution.
8
#include <sys/time.h> // for struct timeval
9
#if defined(__linux__) && defined(__i386__)
10
# define rdtscl(low) \
11
__asm__ __volatile__("rdtsc" : "=a" (low) : : "edx")
19
const usec_t UsecPerSec = INT64_CONSTANT(1000000);
22
bool Clock::UsingCPU = std::getenv("CLOCK_USE_CPU") ? true : false;
24
// -----------------------------------------------------------------------------
25
usec_t Clock::time(void)
28
static bool warn = true;
31
std::cout << "Using CPU clock." << std::endl;
35
#if defined(__linux__) && defined(__i386__)
44
std::cerr << "CPU clock not implemented for this architecture" << std::endl;
52
gettimeofday(&tv, NULL);
53
return (usec_t) (tv.tv_sec * UsecPerSec + tv.tv_usec);
57
// -----------------------------------------------------------------------------
66
// -----------------------------------------------------------------------------
72
// -----------------------------------------------------------------------------
73
usec_t Clock::elapsed(void) const
78
return time() - _start;
82
// -----------------------------------------------------------------------------
83
usec_t Clock::start(void)
87
return _start = time();
90
// -----------------------------------------------------------------------------
91
usec_t Clock::stop(void)