Example #1
0
        /// <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;
            }
        }
Example #2
0
        /// <inheritdoc />
        public void Dispose()
        {
            StopwatchUpdate.Stop();
            StopwatchUpdate = default;

            StopwatchFrame.Stop();
            StopwatchFrame = default;
        }
Example #3
0
 private void DisposeStopwatchFrame()
 {
     if (StopwatchFrame == null)
     {
         throw new NullReferenceException("StopwatchFrame in Engine\\Render\\FramesPerSecondCounter is NULL");
     }
     StopwatchFrame.Stop();
     StopwatchFrame = default;
 }
Example #4
0
        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;
            }
        }
Example #5
0
 /// <summary>
 /// Start frame measurement.
 /// </summary>
 public void StartFrame()
 {
     StopwatchFrame.Restart();
 }