Example #1
0
 public void Enable()
 {
     Profiler.Enable(GcCollectionCountKey);
     Profiler.Enable(GcMemoryKey);
     gcMemoryState.CheckIfEnabled();
     collectionCountState.CheckIfEnabled();
 }
Example #2
0
        private void DrawFrame()
        {
            if (SlowDownDrawCalls && (UpdateTime.FrameCount & 1) == 1) // skip the draw call about one frame over two.
            {
                return;
            }

            try
            {
                // Initialized
                if (!profilingDraw.IsInitialized)
                {
                    profilingDraw = Profiler.Begin(GameProfilingKeys.GameDrawFPS);
                }

                // Update profiling data
                profilingDraw.CheckIfEnabled();

                if (!isExiting && GameSystems.IsFirstUpdateDone && !Window.IsMinimized)
                {
                    drawTime.Update(totalDrawTime, lastFrameElapsedGameTime, singleFrameUpdateTime, drawRunningSlowly, true);

                    if (drawTime.FramePerSecondUpdated)
                    {
                        // TODO: store some GameTime information as attributes in the Profiling using  profilingDraw.SetAttribute(..)
                        profilingDraw.Mark("Frame = {0}, Update = {1:0.000}ms, Draw = {2:0.000}ms, FPS = {3:0.00}", drawTime.FrameCount, updateTime.TimePerFrame.TotalMilliseconds, drawTime.TimePerFrame.TotalMilliseconds, drawTime.FramePerSecond);
                    }

                    using (Profiler.Begin(GameProfilingKeys.GameDraw))
                    {
                        Draw(drawTime);
                    }
                }
            }
            finally
            {
                lastFrameElapsedGameTime = TimeSpan.Zero;
            }
        }