How to get duration, as int milli's and float seconds from ?

前端 未结 4 1166
甜味超标
甜味超标 2020-12-04 07:54

I\'m trying to use chrono library for timers and durations.

I want to be able to have a Duration frameStart; ( from app start ) and a Duration fra

4条回答
  •  粉色の甜心
    2020-12-04 08:16

    Is this what you're looking for?

    #include 
    #include 
    
    int main()
    {
        typedef std::chrono::high_resolution_clock Time;
        typedef std::chrono::milliseconds ms;
        typedef std::chrono::duration fsec;
        auto t0 = Time::now();
        auto t1 = Time::now();
        fsec fs = t1 - t0;
        ms d = std::chrono::duration_cast(fs);
        std::cout << fs.count() << "s\n";
        std::cout << d.count() << "ms\n";
    }
    

    which for me prints out:

    6.5e-08s
    0ms
    

提交回复
热议问题