mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 21:02:17 +02:00
change long int to long in CounterStats
This commit is contained in:
parent
9b73d2559d
commit
83ee450759
2 changed files with 46 additions and 48 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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__) */
|
||||
|
|
Loading…
Reference in a new issue