File:  [Isaki's NoNo m68k/m88k emulator] / nono / lib / perfcounter.cpp
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed Apr 29 17:04:40 2026 UTC (2 months, 3 weeks ago) by root
Branches: MAIN, Isaki
CVS tags: v014, v013, v012, v011, v010, v009, v008, v007, v006, HEAD
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");
	}
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.