2730f2d35f
Reviewers: mtomic, teon.banek, mferencevic Reviewed By: mtomic, teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1772
23 lines
461 B
C++
23 lines
461 B
C++
#pragma once
|
|
|
|
#include <chrono>
|
|
|
|
namespace utils {
|
|
|
|
// This class is threadsafe.
|
|
class Timer {
|
|
public:
|
|
Timer() : start_time_(std::chrono::steady_clock::now()) {}
|
|
|
|
template <typename TDuration = std::chrono::duration<double>>
|
|
TDuration Elapsed() const {
|
|
return std::chrono::duration_cast<TDuration>(
|
|
std::chrono::steady_clock::now() - start_time_);
|
|
}
|
|
|
|
private:
|
|
std::chrono::steady_clock::time_point start_time_;
|
|
};
|
|
|
|
} // namespace utils
|