Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TIMEMEASUREMENT_H_
00020 #define TIMEMEASUREMENT_H_
00021
00022 #include <time.h>
00023 #include <iostream>
00024 #include <sys/types.h>
00025 #include <stdint.h>
00026
00027 namespace ibrcommon
00028 {
00029 class TimeMeasurement
00030 {
00031 public:
00032 TimeMeasurement();
00033 virtual ~TimeMeasurement();
00034
00035 void start();
00036 void stop();
00037
00038 u_int64_t getNanoseconds() const;
00039 float getMicroseconds() const;
00040 float getMilliseconds() const;
00041 float getSeconds() const;
00042
00043 friend std::ostream &operator<<(std::ostream &stream, const TimeMeasurement &measurement);
00044
00045 static std::ostream& format(std::ostream &stream, const float value);
00046
00047 private:
00048 static int64_t timespecDiff(const struct timespec *timeA_p, const struct timespec *timeB_p);
00049 static int64_t timespecDiff(const uint64_t &stop, const uint64_t &start);
00050
00051 struct timespec _start;
00052 struct timespec _end;
00053
00054 uint64_t _uint64_start;
00055 uint64_t _uint64_end;
00056 };
00057 }
00058
00059 #endif