C++时间函数模板

//测时间
class Timer {
private:
    clock_t _start;
    clock_t _end;
    
public:
    Timer() { start(); }
    void start() {
        _start = clock();
    }
    double get() {
        _end = clock();
        double usedtime = double(_end - _start) / CLK_TCK;
        cout << "used time: " <<  usedtime << " s\n";
        return usedtime;
    }
};

 

posted @ 2016-08-23 14:41  chenhuan001  阅读(222)  评论(0编辑  收藏  举报