ctimer.h

来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C头文件 代码 · 共 36 行

H
36
字号
#ifndef _CTIMER_H#define _CTIMER_H// a class that can be used to "time" parts of programs// or as a general timer//// operations are:////     Start() : starts the timer //     Stop()  : stops the timer//     ElapsedTime() : returns the elapsed time between //                     start and the last stop//     CumulativeTime(): returns cumulative total of all//                      "laps" (timed intervals), i.e., sum of//                      calls to ElapsedTime//     Reset()    : resets cumulative time to 0//                  so "removes" history of timer////class CTimer{  public:    CTimer();                         // constructor    void Reset();                     // reset timer to 0    void Start();                     // begin timing    void Stop();                      // stop timing    double ElapsedTime();             // between last start/stop    double CumulativeTime();          // total of all times since reset  private:    long myStartTime,myEndTime;    double myElapsed;                 // time since start and last stop    double myCumulative;              // cumulative of all "lap" times};#endif      // _CTIMER_H not defined

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?