ppsspp/Common/Math/Statistics.h
Henrik Rydgård d4bfe9299d Track min and max GPU time, init time, render CPU time.
Mainly wanted to see if init time is a factor, there are optimizations
we can do there.
2022-10-10 10:53:27 +02:00

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_;
};