windows api 和 boost计时 微秒级

windows api
boost计时代码,微秒级

    #include <boost/date_time/posix_time/posix_time.hpp>

    LARGE_INTEGER freq, start, end;
    QueryPerformanceFrequency(&freq);
    QueryPerformanceCounter(&start);
    ::Sleep(1000);
    QueryPerformanceCounter(&end);
    double tm = (end.QuadPart - start.QuadPart)*1.0 / freq.QuadPart;
    std::cout << tm << std::endl;

    boost::posix_time::ptime ptStart = boost::posix_time::microsec_clock::local_time();
    ::Sleep(1000);
    boost::posix_time::ptime ptEnd = boost::posix_time::microsec_clock::local_time();
    std::string strTime = boost::posix_time::to_iso_string(ptEnd-ptStart);
    std::cout << strTime << std::endl;

你可能感兴趣的:(windows api 和 boost计时 微秒级)