C++常用库

2021/5/11 22:55:08

本文主要是介绍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;

 



这篇关于C++常用库的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程