diff options
Diffstat (limited to '')
| -rw-r--r-- | src/unstable/speedometer.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/unstable/speedometer.h b/src/unstable/speedometer.h new file mode 100644 index 0000000..84d21ed --- /dev/null +++ b/src/unstable/speedometer.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | #ifndef BU_SPEEDOMETER_H | ||
| 2 | #define BU_SPEEDOMETER_H | ||
| 3 | |||
| 4 | #include "bu/mutex.h" | ||
| 5 | |||
| 6 | #include <stdint.h> | ||
| 7 | |||
| 8 | namespace Bu | ||
| 9 | { | ||
| 10 | class Speedometer | ||
| 11 | { | ||
| 12 | public: | ||
| 13 | Speedometer( int64_t iBucketMs, int32_t iBucketCount ); | ||
| 14 | virtual ~Speedometer(); | ||
| 15 | |||
| 16 | void addEvent(); | ||
| 17 | double getSpeed(); | ||
| 18 | int32_t getTotalEvents(); | ||
| 19 | void debug(); | ||
| 20 | |||
| 21 | private: | ||
| 22 | void _updateBuckets( int64_t iNow ); | ||
| 23 | /** | ||
| 24 | * Gets the current time in milliseconds. | ||
| 25 | */ | ||
| 26 | int64_t getCurrentTime() const; | ||
| 27 | |||
| 28 | private: | ||
| 29 | uint32_t *aiBucket; | ||
| 30 | uint32_t iTotal; | ||
| 31 | int32_t iCapacity; | ||
| 32 | int32_t iFill; | ||
| 33 | int32_t iStart; | ||
| 34 | int32_t iCurrent; | ||
| 35 | int64_t iBucketMs; | ||
| 36 | int64_t iStartTime; | ||
| 37 | int64_t iWindowSizeMs; | ||
| 38 | int64_t iLastUpdate; | ||
| 39 | mutable Bu::Mutex mLock; | ||
| 40 | }; | ||
| 41 | } | ||
| 42 | |||
| 43 | #endif | ||
