14#ifndef MINOTAURTIMER_H
15#define MINOTAURTIMER_H
20#define CLOCKS_PER_SEC 1000000
24#include <sys/resource.h>
27#define MICROSEC 1000000
44 virtual void start() = 0;
45 virtual void stop() = 0;
46 virtual double query()
const = 0;
48 virtual double wQuery()
const
50 using namespace std::chrono;
51 steady_clock::time_point currentTime = steady_clock::now();
52 duration<double> time_span =
53 duration_cast<duration<double>>(currentTime - w_);
54 return time_span.count();
58 std::chrono::steady_clock::time_point w_;
59 bool is_started_ =
false;
77 : is_started_(
false) {};
83 w_ = std::chrono::steady_clock::now();
99 throw(
"Some exception");
102 return ((
double)(clock() - s_) / (
double)CLOCKS_PER_SEC);
106#ifdef MINOTAUR_RUSAGE
111 class UsageTimer :
public Timer {
118 : is_started_(false) {};
124 getrusage(RUSAGE_SELF, &s_);
139 double t1, t2, m1, m2, s1, s2, m, s;
142 throw(
"Some exception");
144 getrusage(RUSAGE_SELF, &e);
146 m1 = (double)e.ru_utime.tv_usec;
147 m2 = (
double)s_.ru_utime.tv_usec;
150 s1 = (double)e.ru_utime.tv_sec;
151 s2 = (
double)s_.ru_utime.tv_sec;
154 t1 = s + m / MICROSEC;
156 m1 = (double)e.ru_stime.tv_usec;
157 m2 = (
double)s_.ru_stime.tv_usec;
160 s1 = (double)e.ru_stime.tv_sec;
161 s2 = (
double)s_.ru_stime.tv_sec;
164 t2 = s + m / MICROSEC;
183#ifdef MINOTAUR_RUSAGE
184 return new UsageTimer;
Declare important 'types' used in Minotaur.
void stop()
Stop the timer. Can not query after this.
Definition: Timer.h:90
void start()
Start the timer.
Definition: Timer.h:81
The TimerFactory should be used to get the approrpriate Timer.
Definition: Timer.h:172
virtual ~TimerFactory()
Destroy.
Definition: Timer.h:178
TimerFactory()
Default constructor.
Definition: Timer.h:175
virtual Timer * getTimer()
Return an appropriate Timer.
Definition: Timer.h:181
Definition: ActiveNodeStore.h:20