|
|
nono 0.1.2
//
// nono
// Copyright (C) 2020 nono project
// Licensed under nono-license.txt
//
#include "perfcounter.h"
//
// パフォーマンス測定
//
// コンストラクタ
PerfCounter::PerfCounter(int xxx_)
{
xxx = xxx_;
}
// 結果の集計と表示
void
PerfCounter::PrintResult()
{
total_elapsed += duration_cast<microseconds>(end - start).count();
if (++total_count >= xxx) {
int fps = 1000 * 1000 / (total_elapsed / total_count);
total_elapsed = 0;
total_count = 0;
printf("%d fps", fps);
fpsarray.push_back(fps);
if (fpsarray.size() > 4) {
fpsarray.pop_front();
}
if (fpsarray.size() > 2) {
int minv = 1e9;
int sum = 0;
for (auto v : fpsarray) {
if (v < minv)
minv = v;
sum += v;
}
// 最悪値1つを除いた移動平均
sum -= minv;
int avg = sum / (fpsarray.size() - 1);
printf(" (avg %d)", avg);
}
printf("\n");
}
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.