2020-11-13 15:37:10 +00:00
|
|
|
#include <chrono>
|
|
|
|
#include <iosfwd>
|
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
namespace common2
|
2020-11-13 15:37:10 +00:00
|
|
|
{
|
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
class Timer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Timer();
|
|
|
|
void tic();
|
|
|
|
void toc();
|
2020-11-13 20:12:51 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
double getTimeInSeconds() const;
|
2020-11-13 15:37:10 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
friend std::ostream& operator<<(std::ostream& os, const Timer & timer);
|
2020-11-13 15:37:10 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
private:
|
2020-11-13 15:37:10 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
std::chrono::time_point<std::chrono::steady_clock> myT0;
|
2020-11-13 15:37:10 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
double mySum;
|
|
|
|
double mySum2;
|
|
|
|
int myN;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& os, const Timer & timer);
|
|
|
|
|
|
|
|
}
|