C++11 std::chrno简单运用

//该程序意在输出10分之1秒的系统时间戳
void printTimestamp(void)
{
    using namespace std::chrono;

    typedef typename duration<long, std::ratio<1, 10>> mseconds;
    time_point<system_clock, mseconds> tp = time_point_cast<mseconds>(system_clock::now());
    auto tmp = duration_cast<mseconds>(tp.time_since_epoch());
    auto timeStamp = tmp.count();

    printf("Current timeStamp(10 percent of a second)==%lu\n", timeStamp);
}

 

posted @ 2018-07-02 10:10  albertPaul  阅读(371)  评论(0编辑  收藏  举报