oh_my_loam/common/tic_toc.h

25 lines
485 B
C
Raw Normal View History

2020-10-09 21:04:25 +08:00
#pragma once
#include <chrono>
#include <cstdlib>
#include <ctime>
2020-10-12 21:09:32 +08:00
namespace oh_my_loam {
2020-10-09 21:04:25 +08:00
class TicToc {
public:
TicToc() { tic(); }
void tic() { start_ = std::chrono::system_clock::now(); }
double toc() {
end_ = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end_ - start_;
return elapsed_seconds.count() * 1000;
}
private:
std::chrono::time_point<std::chrono::system_clock> start_, end_;
};
2020-10-13 01:07:59 +08:00
} // namespace oh_my_loam