C++ Library for Competitive Programming
#include "emthrm/util/timer.hpp"
struct Timer;
名前 | 効果・戻り値 |
---|---|
Timer(); |
コンストラクタ |
void reset(); |
リセットする。 |
template <typename PeriodType = std::chrono::milliseconds> long long elapsed() const;
|
経過時間 |
#ifndef EMTHRM_UTIL_TIMER_HPP_
#define EMTHRM_UTIL_TIMER_HPP_
#include <chrono>
namespace emthrm {
struct Timer {
Timer() { reset(); }
void reset() { bgn = std::chrono::high_resolution_clock::now(); }
template <typename PeriodType = std::chrono::milliseconds>
long long elapsed() const {
const std::chrono::high_resolution_clock::time_point end =
std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<PeriodType>(end - bgn).count();
}
private:
std::chrono::high_resolution_clock::time_point bgn;
};
} // namespace emthrm
#endif // EMTHRM_UTIL_TIMER_HPP_
#line 1 "include/emthrm/util/timer.hpp"
#include <chrono>
namespace emthrm {
struct Timer {
Timer() { reset(); }
void reset() { bgn = std::chrono::high_resolution_clock::now(); }
template <typename PeriodType = std::chrono::milliseconds>
long long elapsed() const {
const std::chrono::high_resolution_clock::time_point end =
std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<PeriodType>(end - bgn).count();
}
private:
std::chrono::high_resolution_clock::time_point bgn;
};
} // namespace emthrm