From 83ee4507596382c984c903a43d52272d5280f283 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 12 Apr 2013 15:18:04 -0700 Subject: [PATCH] change long int to long in CounterStats --- libraries/shared/src/CounterStats.cpp | 12 ++-- libraries/shared/src/CounterStats.h | 82 +++++++++++++-------------- 2 files changed, 46 insertions(+), 48 deletions(-) diff --git a/libraries/shared/src/CounterStats.cpp b/libraries/shared/src/CounterStats.cpp index 7dbab0add6..050ee6159b 100644 --- a/libraries/shared/src/CounterStats.cpp +++ b/libraries/shared/src/CounterStats.cpp @@ -33,17 +33,17 @@ // int sampleAt; -void CounterStatHistory::recordSample(long int thisCount) { +void CounterStatHistory::recordSample(long thisCount) { timeval now; gettimeofday(&now,NULL); double nowSeconds = (now.tv_usec/1000000.0)+(now.tv_sec); this->recordSample(nowSeconds,thisCount); } -void CounterStatHistory::recordSample(double thisTime, long int thisCount) { +void CounterStatHistory::recordSample(double thisTime, long thisCount) { // how much did we change since last sample? - long int thisDelta = thisCount - this->lastCount; + long thisDelta = thisCount - this->lastCount; double elapsed = thisTime - this->lastTime; // record the latest values @@ -74,12 +74,12 @@ void CounterStatHistory::recordSample(double thisTime, long int thisCount) { } -long int CounterStatHistory::getRunningAverage() { +long CounterStatHistory::getRunningAverage() { // before we calculate our running average, always "reset" the current count, with the current time // this will flush out old data, if we haven't been adding any new data. this->recordSample(this->currentCount); - long int runningTotal = 0; + long runningTotal = 0; double minTime = this->timeSamples[0]; double maxTime = this->timeSamples[0]; @@ -90,6 +90,6 @@ long int CounterStatHistory::getRunningAverage() { } double elapsedTime = maxTime-minTime; - long int runningAverage = runningTotal/elapsedTime; + long runningAverage = runningTotal/elapsedTime; return runningAverage; } diff --git a/libraries/shared/src/CounterStats.h b/libraries/shared/src/CounterStats.h index 29481461b6..36b91c6937 100644 --- a/libraries/shared/src/CounterStats.h +++ b/libraries/shared/src/CounterStats.h @@ -22,58 +22,56 @@ #define COUNTETSTATS_TIME_FRAME (COUNTETSTATS_SAMPLES_TO_KEEP*COUNTETSTATS_TIME_BETWEEN_SAMPLES) class CounterStatHistory { - +public: + std::string name; + + CounterStatHistory(std::string myName): + currentCount(0), currentDelta(0),currentTime(0.0), + lastCount(0),lastTime(0.0), + totalTime(0.0), + sampleAt(-1), sampleCount(0), name(myName) {}; + + CounterStatHistory(): + currentCount(0), currentDelta(0),currentTime(0.0), + lastCount(0),lastTime(0.0), + totalTime(0.0), + sampleAt(-1), sampleCount(0) {}; + + CounterStatHistory(std::string myName, double initialTime, long int initialCount) : + currentCount(initialCount), currentDelta(0), currentTime(initialTime), + lastCount(initialCount),lastTime(initialTime), + totalTime(initialTime), + sampleAt(-1), sampleCount(0), name(myName) {}; + + void recordSample(long thisCount); + void recordSample(double thisTime, long thisCount); + long getRunningAverage(); + + long getAverage() { + return currentCount/totalTime; + }; + + double getTotalTime() { + return totalTime; + }; + long getCount() { + return currentCount; + }; private: - long int currentCount; - long int currentDelta; + long currentCount; + long currentDelta; double currentTime; - long int lastCount; + long lastCount; double lastTime; double totalTime; - long int countSamples[COUNTETSTATS_SAMPLES_TO_KEEP]; - long int deltaSamples[COUNTETSTATS_SAMPLES_TO_KEEP]; + long countSamples[COUNTETSTATS_SAMPLES_TO_KEEP]; + long deltaSamples[COUNTETSTATS_SAMPLES_TO_KEEP]; double timeSamples[COUNTETSTATS_SAMPLES_TO_KEEP]; int sampleAt; int sampleCount; - -public: - std::string name; - - CounterStatHistory(std::string myName): - currentCount(0), currentDelta(0),currentTime(0.0), - lastCount(0),lastTime(0.0), - totalTime(0.0), - sampleAt(-1),sampleCount(0), name(myName) {}; - - CounterStatHistory(): - currentCount(0), currentDelta(0),currentTime(0.0), - lastCount(0),lastTime(0.0), - totalTime(0.0), - sampleAt(-1),sampleCount(0) {}; - - CounterStatHistory(std::string myName, double initialTime, long int initialCount) : - currentCount(initialCount), currentDelta(0), currentTime(initialTime), - lastCount(initialCount),lastTime(initialTime), - totalTime(initialTime), - sampleAt(-1), sampleCount(0), name(myName) {}; - - void recordSample(long int thisCount); - void recordSample(double thisTime, long int thisCount); - long int getRunningAverage(); - - long int getAverage() { - return currentCount/totalTime; - }; - - double getTotalTime() { - return totalTime; - }; - long int getCount() { - return currentCount; - }; }; #endif /* defined(__hifi__CounterStat__) */