mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-12-11 07:34:08 +00:00
d4bfe9299d
Mainly wanted to see if init time is a factor, there are optimizations we can do there.
43 lines
763 B
C++
43 lines
763 B
C++
#pragma once
|
|
|
|
#include <cmath>
|
|
|
|
// Very simple stat for convenience. Keeps track of min, max, smoothed.
|
|
struct SimpleStat {
|
|
SimpleStat(const char *name) : name_(name) { Reset(); }
|
|
|
|
void Update(double value) {
|
|
value_ = value;
|
|
if (min_ == INFINITY) {
|
|
smoothed_ = value;
|
|
} else {
|
|
// TODO: Make factor adjustable?
|
|
smoothed_ = 0.99 * smoothed_ + 0.01 * value;
|
|
}
|
|
if (value < min_) {
|
|
min_ = value;
|
|
}
|
|
if (value > max_) {
|
|
max_ = value;
|
|
}
|
|
}
|
|
|
|
void Reset() {
|
|
value_ = 0.0;
|
|
smoothed_ = 0.0; // doens't really need init
|
|
min_ = INFINITY;
|
|
max_ = -INFINITY;
|
|
}
|
|
|
|
void Format(char *buffer, size_t sz);
|
|
|
|
private:
|
|
const char *name_;
|
|
|
|
// These are initialized in Reset().
|
|
double value_;
|
|
double min_;
|
|
double max_;
|
|
double smoothed_;
|
|
};
|