CL-CBS
timer.hpp
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <chrono>
13 #include <iostream>
18 class Timer {
19  public:
21  : start_(std::chrono::high_resolution_clock::now()),
22  end_(std::chrono::high_resolution_clock::now()) {}
23 
24  void reset() { start_ = std::chrono::high_resolution_clock::now(); }
25 
26  void stop() { end_ = std::chrono::high_resolution_clock::now(); }
27 
28  double elapsedSeconds() const {
29  auto timeSpan = std::chrono::duration_cast<std::chrono::duration<double>>(
30  end_ - start_);
31  return timeSpan.count();
32  }
33 
34  private:
35  std::chrono::high_resolution_clock::time_point start_;
36  std::chrono::high_resolution_clock::time_point end_;
37 };
void reset()
Definition: timer.hpp:24
Timer()
Definition: timer.hpp:20
class for counting time (microsecond)
Definition: timer.hpp:18
void stop()
Definition: timer.hpp:26
double elapsedSeconds() const
Definition: timer.hpp:28