C++常用库

 

 

#include <chrono>
    /// nanoseconds
    typedef duration<_GLIBCXX_CHRONO_INT64_T, nano>         nanoseconds;

    /// microseconds
    typedef duration<_GLIBCXX_CHRONO_INT64_T, micro>         microseconds;

    /// milliseconds
    typedef duration<_GLIBCXX_CHRONO_INT64_T, milli>         milliseconds;

    /// seconds
    typedef duration<_GLIBCXX_CHRONO_INT64_T>             seconds;

    /// minutes
    typedef duration<_GLIBCXX_CHRONO_INT64_T, ratio< 60>>   minutes;

    /// hours
    typedef duration<_GLIBCXX_CHRONO_INT64_T, ratio<3600>>  hours;

计时

const auto tp_1 = std::chrono::steady_clock::now();
matcher->match(desc_1, desc_2, matches);
const auto tp_2 = std::chrono::steady_clock::now();

const auto track_time = std::chrono::duration_cast<std::chrono::milliseconds>(tp_2 - tp_1).count();
td::cout<<"match_time: "<<track_time<<"ms" <<std::endl;

 

上一篇:10机器学习之监督学习


下一篇:9 使用析构函数防止资源泄漏