using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
namespace ISCamRecorder {
internal class FrameRateCounter {
Stopwatch _Swatch = new Stopwatch(); // 高精度時間計測
int _Count = 0; // FPSを計算する回数
int _Counter = 0; // 現在のカウント
public float FrameRate { get; private set; } = 0; // FPS値
/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="count"></param>
public FrameRateCounter(int count) {
_Count = count;
_Swatch.Start();
}
/// <summary>
/// 計時
/// </summary>
public void Shot() {
if (++_Counter >= _Count) {
var elapsed = _Swatch.ElapsedMilliseconds;
FrameRate = _Count * 1000F / elapsed;
_Counter = 0;
_Swatch.Restart();
}
}
}
}