C++#include <chrono>
#ifndef __MY_TIMER__
#define __MY_TIMER__ QwQ
namespace my{
template <typename _Tp = double, typename _Clock = std::chrono::steady_clock>
class timer{
private:
typedef typename std::chrono::duration<_Tp, std::ratio<1, 1> > _Dur;
typedef typename std::chrono::time_point<_Clock, _Dur> _Point;
int _cnt;
_Point _start_time;
public:
timer() : _cnt(0), _start_time(_Clock::now()) { }
void start() { ++_cnt; _start_time = _Clock::now(); return ; }
_Tp duration() { _Point _end_time(_Clock::now()); return (_end_time - _start_time).count(); }
int count() { return _cnt; }
};
}
#endif