41 std::list<double>::iterator i, e;
57 double variance, average, size;
59 if ( (size = (
double)
entries.size()) <= 1) {
65 std::list<double>::iterator i, e;
67 variance += (*i-average)*(*i-average);
78 if (!size) {
mutex.leave();
return 0; }
79 else if (size == 1) { result =
entries.front();
mutex.leave();
return result; }
80 else if (size == 2) { result = (
entries.front() +
entries.back()) / 2.0;
mutex.leave();
return result; }
84 std::list<double>::iterator i =
entries.begin(), e =
entries.end();
87 for (uint32 n = 0; n < half; n++)
93 for (uint32 n = 0; n < half - 1; n++)
97 result = (result + (*i)) / 2.0;
110 result = (uint32)
entries.size();
133 if (stats.
getSum() != 128) {
160 if (abs(stats.
getStdDev() - 32.11697) > 0.0001) {
171 "Statistics: count, sum, average, median, variance, standard deviation",
"core");
Time-binned moving average / throughput tracker.
Small, dependency-free unit test harness used by all CMSDK object tests.
Stats(uint32 maxCount=10000)
Create a collector.
std::list< double > entries
bool clear()
Remove all samples.
bool add(double val)
Add a sample, evicting the oldest when the window is full.
static bool UnitTest()
Self test.
static UnitTestRunner & instance()
Access the singleton (created on first use).
void registerTest(const char *name, UnitTestFunc func, const char *description="", const char *category="", bool inDefaultRun=true)
Register a test with the runner.
void fail(const char *fmt,...)
Set an explanatory reason shown on the FAIL line.
void progress(int percent, const char *action)
Report progress with a short description of the current action.
void Register_Stats_Tests()