thesis version
This commit is contained in:
41
celero/inc/udm.h
Normal file
41
celero/inc/udm.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef BENCH_INC_UDM_H
|
||||
#define BENCH_INC_UDM_H
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include "../celero/Celero.h"
|
||||
|
||||
class GetRusageUDM: public celero::UserDefinedMeasurementTemplate<std::size_t> {
|
||||
std::string getName() const override { return "time"; }
|
||||
|
||||
bool reportSize() const override { return false; }
|
||||
// bool reportMean() const override { return false; }
|
||||
bool reportVariance() const override { return false; }
|
||||
bool reportStandardDeviation() const override { return false; }
|
||||
bool reportSkewness() const override { return false; }
|
||||
bool reportKurtosis() const override { return false; }
|
||||
bool reportZScore() const override { return false; }
|
||||
bool reportMin() const override { return false; }
|
||||
bool reportMax() const override { return false; }
|
||||
};
|
||||
|
||||
class GetRusage {
|
||||
int _who;
|
||||
struct rusage _begin, _end;
|
||||
int _iterations;
|
||||
|
||||
public:
|
||||
explicit GetRusage(int who = RUSAGE_SELF): _who{who} {}
|
||||
void start(int iterations) { _iterations = iterations; getrusage(_who, &_begin); }
|
||||
void stop() { getrusage(_who, &_end); }
|
||||
|
||||
std::size_t get() {
|
||||
auto begin = _begin.ru_utime, end = _end.ru_utime;
|
||||
auto totalUs = (end.tv_sec - begin.tv_sec) * 1e6 + (end.tv_usec - begin.tv_usec);
|
||||
return totalUs/_iterations;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user