#include #include typedef std::chrono::high_resolution_clock _timerClock; typedef long long __int64; __int64 TimerInit() { _timerClock::time_point t1 = _timerClock::now(); return __int64(std::chrono::duration_cast (t1.time_since_epoch()).count()); } double TimerDiff(__int64 start) { _timerClock::time_point t1 = _timerClock::now(); return double(__int64(std::chrono::duration_cast (t1.time_since_epoch()).count()) - start) / 1000000; } int main() { auto MyTimer = TimerInit(); std::cout << MyTimer << std::endl; sleep(2); std::cout << TimerDiff(MyTimer) << std::endl; return 0; }