[模板] 计时 Timing
Templates 其他
Lastmod: 2021-04-25 周日 18:22:07

计时 Timing

chrono

class Timing
{
private:
    typedef chrono::time_point<std::chrono::high_resolution_clock> TP;
    TP current_time()
    { return chrono::high_resolution_clock::now(); }
    TP st,ed;
public:
    void start() { st=current_time(); }
    void end() { ed=current_time(); }
    void print()
    { 
        cout<<chrono::duration_cast<chrono::microseconds>(ed-st).count()
            <<"ms\n";
    }
}timing;
Prev: [模板] C++ Debug
Next: [模板][数据结构] 树状数组 Binary Index Tree/Fenwick Tree