mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
5e370db6c5
6000 matmuls CG unprec 2000 matmuls CG prec (4000 eo muls) 1050 matmuls PGCR on 16^3 x 32 x 8 m=.01 Substantial effort on timing and logging infrastructure
45 lines
965 B
C++
45 lines
965 B
C++
#ifndef GRID_TIME_H
|
|
#define GRID_TIME_H
|
|
namespace Grid {
|
|
// Dress the output; use std::chrono
|
|
#include <chrono>
|
|
#include <ctime>
|
|
|
|
typedef std::chrono::system_clock GridClock;
|
|
typedef std::chrono::time_point<GridClock> GridTimePoint;
|
|
typedef std::chrono::milliseconds GridTime;
|
|
|
|
|
|
class GridStopWatch {
|
|
private:
|
|
bool running;
|
|
GridTimePoint start;
|
|
GridTime accumulator;
|
|
public:
|
|
GridStopWatch () {
|
|
Reset();
|
|
}
|
|
void Start(void) {
|
|
assert(running == false);
|
|
start = GridClock::now();
|
|
running = true;
|
|
}
|
|
void Stop(void) {
|
|
assert(running == true);
|
|
accumulator+= std::chrono::duration_cast<GridTime>(GridClock::now()-start);
|
|
running = false;
|
|
};
|
|
void Reset(void){
|
|
running = false;
|
|
start = GridClock::now();
|
|
accumulator = std::chrono::duration_cast<GridTime>(start-start);
|
|
}
|
|
GridTime Elapsed(void) {
|
|
assert(running == false);
|
|
return accumulator;
|
|
}
|
|
};
|
|
|
|
}
|
|
#endif
|