show fps on c# winforms
DateTime _lastCheckTime = DateTime.Now;
long _frameCount = 0;
// called whenever a map is updated
void OnMapUpdated()
{
Interlocked.Increment(ref _frameCount);
}
// called every once in a while
double GetFps()
{
double secondsElapsed = (DateTime.Now - _lastCheckTime).TotalSeconds;
long count = Interlocked.Exchange(ref _frameCount, 0);
double fps = count / secondsElapsed;
_lastCheckTime = DateTime.Now;
return fps;
}