/// <summary> /// Stop frame measurement. /// </summary> public void StopFrame() { StopwatchFrame.Stop(); // add elapsed time of this frame Elapsed += StopwatchFrame.Elapsed; // increment frame count to respectively keep ratio FrameCount++; // check if we need to do average measurement var updateElapsed = StopwatchUpdate.Elapsed; if (updateElapsed >= UpdateRate) { // calc averages FpsRender = FrameCount / Elapsed.TotalSeconds; FpsGlobal = FrameCount / updateElapsed.TotalSeconds; // reset StopwatchUpdate.Restart(); Elapsed = TimeSpan.Zero; FrameCount = 0; } }
/// <inheritdoc /> public void Dispose() { StopwatchUpdate.Stop(); StopwatchUpdate = default; StopwatchFrame.Stop(); StopwatchFrame = default; }
private void DisposeStopwatchFrame() { if (StopwatchFrame == null) { throw new NullReferenceException("StopwatchFrame in Engine\\Render\\FramesPerSecondCounter is NULL"); } StopwatchFrame.Stop(); StopwatchFrame = default; }
public void StopFrame() { StopwatchFrame.Stop(); Elapsed += StopwatchFrame.Elapsed; FrameCount++; var updateElapsed = StopwatchUpdate.Elapsed; if (updateElapsed >= UpdateRate) { FramesPerSecondForRender = FrameCount / Elapsed.TotalSeconds; FramesPerSecondForGlobal = FrameCount / updateElapsed.TotalSeconds; StopwatchUpdate.Restart(); Elapsed = TimeSpan.Zero; FrameCount = 0; } }
/// <summary> /// Start frame measurement. /// </summary> public void StartFrame() { StopwatchFrame.Restart(); }