Commit 8ec2e204 authored by Robert Menzel's avatar Robert Menzel

fixed a bug in the timer code -> virtual functions should of course not be inlined...

parent 77fdffe3
...@@ -76,14 +76,14 @@ public: ...@@ -76,14 +76,14 @@ public:
inline void restart() { mStartTime = getTimeInNanoseconds(); } inline void restart() { mStartTime = getTimeInNanoseconds(); }
// returns the time in nanosecounds, a 64 bit unsigned int will overflow after 584 years... // returns the time in nanosecounds, a 64 bit unsigned int will overflow after 584 years...
virtual inline uint64_t getTimeInNanoseconds() = 0; virtual uint64_t getTimeInNanoseconds() = 0;
// 32 bit unsigned int with seconds will overflow after 136 years // 32 bit unsigned int with seconds will overflow after 136 years
virtual inline uint32_t getTimeInSeconds() = 0; virtual uint32_t getTimeInSeconds() = 0;
virtual inline double getTimeInSecondsD() = 0; virtual double getTimeInSecondsD() = 0;
// get time diff since last reset: // get time diff since last reset:
virtual inline uint64_t getTimeDiffInNanoseconds() { return getTimeInNanoseconds() - mStartTime; } virtual uint64_t getTimeDiffInNanoseconds() { return getTimeInNanoseconds() - mStartTime; }
// 32 bit unsigned int with seconds will overflow after 136 years // 32 bit unsigned int with seconds will overflow after 136 years
inline uint32_t getTimeDiffInSeconds() { return getTimeInSeconds() - (mStartTime/1000000000); } inline uint32_t getTimeDiffInSeconds() { return getTimeInSeconds() - (mStartTime/1000000000); }
...@@ -92,7 +92,7 @@ public: ...@@ -92,7 +92,7 @@ public:
// get the system dependent resolution of the timing in nanoseconds // get the system dependent resolution of the timing in nanoseconds
// default implementation tests this, better timer implementations should // default implementation tests this, better timer implementations should
// query this info from the system API! // query this info from the system API!
virtual inline uint64_t getTimerResolutionInNanoseconds() { virtual uint64_t getTimerResolutionInNanoseconds() {
uint64_t t0, t1; uint64_t t0, t1;
t0 = t1 = getTimeInNanoseconds(); t0 = t1 = getTimeInNanoseconds();
while (t0 == t1) t1 = getTimeInNanoseconds(); while (t0 == t1) t1 = getTimeInNanoseconds();
...@@ -114,16 +114,16 @@ public: ...@@ -114,16 +114,16 @@ public:
// returns the CPU/Process/Thread time in nanosecounds, a 64 bit unsigned int will overflow after // returns the CPU/Process/Thread time in nanosecounds, a 64 bit unsigned int will overflow after
// 584 years... // 584 years...
inline uint64_t getTimeInNanoseconds() { uint64_t getTimeInNanoseconds() {
return clockToNanoseconds( clock() ); return clockToNanoseconds( clock() );
} }
// 32 bit unsigned int with seconds will overflow after 136 years // 32 bit unsigned int with seconds will overflow after 136 years
inline uint32_t getTimeInSeconds() { uint32_t getTimeInSeconds() {
return (uint32_t) getTimeInSecondsD(); return (uint32_t) getTimeInSecondsD();
} }
inline double getTimeInSecondsD() { double getTimeInSecondsD() {
return (double) clock() / (double) CLOCKS_PER_SEC; return (double) clock() / (double) CLOCKS_PER_SEC;
} }
private: private:
...@@ -167,7 +167,7 @@ public: ...@@ -167,7 +167,7 @@ public:
// returns the CPU/Process/Thread time in nanosecounds, a 64 bit unsigned int will overflow after // returns the CPU/Process/Thread time in nanosecounds, a 64 bit unsigned int will overflow after
// 584 years... // 584 years...
inline uint64_t getTimeInNanoseconds() { uint64_t getTimeInNanoseconds() {
timeval t; timeval t;
gettimeofday( &t, NULL ); gettimeofday( &t, NULL );
uint64_t time = t.tv_sec * 1000000000; // sec to nano uint64_t time = t.tv_sec * 1000000000; // sec to nano
...@@ -176,13 +176,13 @@ public: ...@@ -176,13 +176,13 @@ public:
} }
// 32 bit unsigned int with seconds will overflow after 136 years // 32 bit unsigned int with seconds will overflow after 136 years
inline uint32_t getTimeInSeconds() { uint32_t getTimeInSeconds() {
timeval t; timeval t;
gettimeofday( &t, NULL ); gettimeofday( &t, NULL );
return (uint32_t) (t.tv_sec); return (uint32_t) (t.tv_sec);
} }
inline double getTimeInSecondsD() { double getTimeInSecondsD() {
timeval t; timeval t;
gettimeofday( &t, NULL ); gettimeofday( &t, NULL );
double time = (double) t.tv_sec; double time = (double) t.tv_sec;
...@@ -205,21 +205,21 @@ class PosixTimer : public PerformanceTimerInterface ...@@ -205,21 +205,21 @@ class PosixTimer : public PerformanceTimerInterface
public: public:
PosixTimer() : PerformanceTimerInterface() { restart(); } PosixTimer() : PerformanceTimerInterface() { restart(); }
~PosixTimer() {}; ~PosixTimer() {}
// set the mStartTime to the current time: // set the mStartTime to the current time:
//inline void restart() { timespec t; clock_gettime( TIMER_TYPE, &t); mStartTime = timespecTo64( t ); } //inline void restart() { timespec t; clock_gettime( TIMER_TYPE, &t); mStartTime = timespecTo64( t ); }
// returns the CPU/Process/Thread time in nanosecounds, a 64 bit unsigned int will overflow after // returns the CPU/Process/Thread time in nanosecounds, a 64 bit unsigned int will overflow after
// 584 years... // 584 years...
inline uint64_t getTimeInNanoseconds() { timespec t; clock_gettime( TIMER_TYPE, &t); return timespecTo64(t); } uint64_t getTimeInNanoseconds() { timespec t; clock_gettime( TIMER_TYPE, &t); return timespecTo64(t); }
// 32 bit unsigned int with seconds will overflow after 136 years // 32 bit unsigned int with seconds will overflow after 136 years
inline uint32_t getTimeInSeconds() { timespec t; clock_gettime( TIMER_TYPE, &t); return t.tv_sec; } uint32_t getTimeInSeconds() { timespec t; clock_gettime( TIMER_TYPE, &t); return t.tv_sec; }
inline double getTimeInSecondsD() { timespec t; clock_gettime( TIMER_TYPE, &t); return timespecToDouble(t); } double getTimeInSecondsD() { timespec t; clock_gettime( TIMER_TYPE, &t); return timespecToDouble(t); }
// get the system dependent resolution of the timing in nanoseconds // get the system dependent resolution of the timing in nanoseconds
inline uint64_t getTimerResolutionInNanoseconds() { timespec t; clock_getres( TIMER_TYPE, &t); return timespecTo64(t); } uint64_t getTimerResolutionInNanoseconds() { timespec t; clock_getres( TIMER_TYPE, &t); return timespecTo64(t); }
private: private:
inline uint64_t timespecTo64( const timespec &_time ) const { inline uint64_t timespecTo64( const timespec &_time ) const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment