Merge branch 'refactor' of github.com:slsdetectorgroup/slsDetectorPackage into refactor

This commit is contained in:
2018-12-04 16:05:17 +01:00
6 changed files with 108 additions and 26 deletions

View File

@ -5,34 +5,28 @@
#include <string>
class Timer {
using clock = std::chrono::high_resolution_clock;
using clock = std::chrono::high_resolution_clock;
using time_point = std::chrono::time_point<clock>;
public:
public:
Timer(std::string name = "0")
: t0(clock::now())
, name_(name)
{
: t0(clock::now()), name_(name) {
}
double elapsed_ms()
{
double elapsed_ms() {
return std::chrono::duration<double, std::milli>(clock::now() - t0).count();
}
double elapsed_s()
{
double elapsed_s() {
return std::chrono::duration<double>(clock::now() - t0).count();
}
void print_elapsed()
{
void print_elapsed() {
std::cout << "Timer \"" << name_ << "\": Elapsed time " << elapsed_ms() << " ms\n";
}
void restart()
{
void restart() {
t0 = clock::now();
}
private:
private:
time_point t0;
std::string name_;
};