123456789101112131415161718192021222324252627282930313233343536373839 |
- #include <unistd.h>
- #include <sys/times.h>
- #include <sys/types.h>
- #include <stdlib.h>
- class Time
- {
- public:
- Time():mTicksPerSec(sysconf(_SC_CLK_TCK)), mRealTime(0){mTmsTime.tms_utime=0; mTmsTime.tms_stime=0;}
-
- void getCurrentTime() {mRealTime = times(&mTmsTime);};
- Time& subtract(const Time& Subtrahent);
- Time operator-(const Time& Subtrahent) const;
- void print();
- private:
- long mRealTime;
- struct tms mTmsTime;
- long mTicksPerSec;
- };
- class StopWatch
- {
- public:
- StopWatch();
- void start();
- void stopRound();
- void stop();
- private:
- Time mStartTime;
- Time mStopTime;
- Time mLastStopTime;
- int mRounds;
- };
|