Пример #1
0
        /// <summary>
        /// Resets all frame statistics. Run exactly once per frame.
        /// </summary>
        public void NewFrame()
        {
            if (currentFrame != null)
            {
                currentFrame.Postprocess();
                PendingFrames.Enqueue(currentFrame);
                if (PendingFrames.Count >= max_pending_frames)
                {
                    FrameStatistics oldFrame;
                    PendingFrames.TryDequeue(out oldFrame);
                    FramesHeap.FreeObject(oldFrame);
                }
            }

            currentFrame = FramesHeap.ReserveObject();
            currentFrame.Clear();

            if (HandleGC)
            {
                for (int i = 0; i < lastAmountGarbageCollects.Length; ++i)
                {
                    int amountCollections = GC.CollectionCount(i);
                    if (lastAmountGarbageCollects[i] != amountCollections)
                    {
                        lastAmountGarbageCollects[i] = amountCollections;
                        currentFrame.GarbageCollections.Add(i);
                    }
                }
            }

            for (int i = 0; i < (int)StatisticsCounterType.AmountTypes; ++i)
            {
                AtomicCounter counter = Counters[i];
                if (counter != null)
                {
                    currentFrame.Counts[(StatisticsCounterType)i] = counter.Reset();
                }
            }

            //check for dropped (stutter) frames
            if (Clock.ElapsedFrameTime > spike_time)
            {
                newDroppedFrame();
            }

            //reset frame totals
            currentCollectionTypeStack.Clear();
            //backgroundMonitorStackTrace = null;
            consumeStopwatchElapsedTime();
        }
Пример #2
0
        /// <summary>
        /// Resets all frame statistics. Run exactly once per frame.
        /// </summary>
        public void NewFrame()
        {
            // Reset the counters we keep track of
            for (int i = 0; i < activeCounters.Length; ++i)
            {
                if (activeCounters[i])
                {
                    currentFrame.Counts[(StatisticsCounterType)i] = FrameStatistics.COUNTERS[i];
                    FrameStatistics.COUNTERS[i] = 0;
                }
            }

            PendingFrames.Enqueue(currentFrame);
            if (PendingFrames.Count >= max_pending_frames)
            {
                FrameStatistics oldFrame;
                PendingFrames.TryDequeue(out oldFrame);
                FramesHeap.FreeObject(oldFrame);
            }

            currentFrame = FramesHeap.ReserveObject();
            currentFrame.Clear();

            if (HandleGC)
            {
                for (int i = 0; i < lastAmountGarbageCollects.Length; ++i)
                {
                    int amountCollections = GC.CollectionCount(i);
                    if (lastAmountGarbageCollects[i] != amountCollections)
                    {
                        lastAmountGarbageCollects[i] = amountCollections;
                        currentFrame.GarbageCollections.Add(i);
                    }
                }
            }

            //check for dropped (stutter) frames
            if (Clock.ElapsedFrameTime > spike_time)
            {
                newDroppedFrame();
            }

            //reset frame totals
            currentCollectionTypeStack.Clear();
            //backgroundMonitorStackTrace = null;
            consumeStopwatchElapsedTime();
        }
        /// <summary>
        /// Resets all frame statistics. Run exactly once per frame.
        /// </summary>
        public void NewFrame()
        {
            // Reset the counters we keep track of
            for (int i = 0; i < activeCounters.Length; ++i)
            {
                if (activeCounters[i])
                {
                    currentFrame.Counts[(StatisticsCounterType)i] = FrameStatistics.COUNTERS[i];
                    FrameStatistics.COUNTERS[i] = 0;
                }
            }

            PendingFrames.Enqueue(currentFrame);
            if (PendingFrames.Count >= max_pending_frames)
            {
                PendingFrames.TryDequeue(out FrameStatistics oldFrame);
                FramesHeap.FreeObject(oldFrame);
            }

            currentFrame = FramesHeap.ReserveObject();
            currentFrame.Clear();

            if (HandleGC)
            {
                for (int i = 0; i < lastAmountGarbageCollects.Length; ++i)
                {
                    int amountCollections = GC.CollectionCount(i);
                    if (lastAmountGarbageCollects[i] != amountCollections)
                    {
                        lastAmountGarbageCollects[i] = amountCollections;
                        currentFrame.GarbageCollections.Add(i);
                    }
                }
            }

            //check for dropped (stutter) frames
            traceCollector.NewFrame(Clock.ElapsedFrameTime, Math.Max(10, Math.Max(1000 / Clock.MaximumUpdateHz, AverageFrameTime) * 4));

            //reset frame totals
            currentCollectionTypeStack.Clear();
            consumeStopwatchElapsedTime();
        }