コード例 #1
0
        /// <summary>Returns the number of seconds elapsed since the last call to <see cref="Tic"/>.</summary>
        public static double Toc()
        {
            long stop;

            WinAPI.QueryPerformanceCounter(out stop);
            return((stop - _start) / (double)WinAPI.PerformanceFreq);
        }
コード例 #2
0
        /// <summary>
        ///     Starts / resets a simple performance timer. Returns the number of seconds elapsed since the last call to <see
        ///     cref="Tic"/>, or zero if this is the first call. See also <see cref="Toc"/>.</summary>
        public static double Tic()
        {
            long prevStart = _start;

            WinAPI.QueryPerformanceCounter(out _start);
            return(prevStart == 0 ? 0 : ((_start - prevStart) / (double)WinAPI.PerformanceFreq));
        }
コード例 #3
0
ファイル: FpsCounter.cs プロジェクト: biorpg/RT.Util
        /// <summary>Counts another frame and updates all statistics. Returns the time since the last frame,
        /// or null if this is the first counted frame.</summary>
        public double?CountFrame()
        {
            double?result = null;
            long   count;

            WinAPI.QueryPerformanceCounter(out count);
            if (_lastCount != 0)
            {
                while (_frameTimes.Count > 5 && _frameTimes.Count > AverageFps / 2)
                {
                    delFromStats();
                }
                result = (count - _lastCount) * _secondsPerCount;
                addToStats(result.Value);
            }
            _lastCount = count;
            return(result);
        }