|
|
1.1 ! root 1: // ! 2: // nono ! 3: // Copyright (C) 2020 nono project ! 4: // Licensed under nono-license.txt ! 5: // ! 6: ! 7: #include "perfcounter.h" ! 8: ! 9: // ! 10: // パフォーマンス測定 ! 11: // ! 12: ! 13: // コンストラクタ ! 14: PerfCounter::PerfCounter(int xxx_) ! 15: { ! 16: xxx = xxx_; ! 17: } ! 18: ! 19: // 結果の集計と表示 ! 20: void ! 21: PerfCounter::PrintResult() ! 22: { ! 23: total_elapsed += duration_cast<microseconds>(end - start).count(); ! 24: ! 25: if (++total_count >= xxx) { ! 26: int fps = 1000 * 1000 / (total_elapsed / total_count); ! 27: total_elapsed = 0; ! 28: total_count = 0; ! 29: printf("%d fps", fps); ! 30: ! 31: fpsarray.push_back(fps); ! 32: if (fpsarray.size() > 4) { ! 33: fpsarray.pop_front(); ! 34: } ! 35: if (fpsarray.size() > 2) { ! 36: int minv = 1e9; ! 37: int sum = 0; ! 38: for (auto v : fpsarray) { ! 39: if (v < minv) ! 40: minv = v; ! 41: sum += v; ! 42: } ! 43: // 最悪値1つを除いた移動平均 ! 44: sum -= minv; ! 45: int avg = sum / (fpsarray.size() - 1); ! 46: printf(" (avg %d)", avg); ! 47: } ! 48: printf("\n"); ! 49: } ! 50: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.