コード例 #1
0
ファイル: MemoryGraph.cs プロジェクト: edwinsyarief/Gearset
        internal void Draw(InternalLabeler labeler)
        {
            if (GearsetResources.CurrentRenderPass != RenderPass.BasicEffectPass)
            {
                return;
            }

            if (Visible == false)
            {
                HideLabels(labeler);
                return;
            }

            var graphWidth = Width - LegendWidth;

            //Draw base background, border, size nubbin, title, etc.
            DrawUIView(labeler);

            //Legend indicates collections stats.
            DrawLegend(labeler, Position + new Vector2(15, 15));

            //A bar graph of x frames showing total managed memmory for the process.
            DrawTotalMemoryGraph(graphWidth);

            //Overay a line graph of the managed memory allocated each tick.
            PlotTickMemoryGraph(labeler, graphWidth);
        }
コード例 #2
0
ファイル: MemoryGraph.cs プロジェクト: edwinsyarief/Gearset
 void DrawLegendItem(InternalLabeler labeler, Vector2 position, string labelName, string valueName, string labelText, int value, Color color)
 {
     //Format...[] GenX {count}
     _memoryMonitor.TempBoxDrawer.ShowGradientBoxOnce(position, position - new Vector2(10, 10), color, color);
     labeler.ShowLabel(labelName, position + new Vector2(4, -10), labelText, color);
     _stringBuilder.SetText(value);
     labeler.ShowLabelEx(valueName, position + new Vector2(44, -10), _stringBuilder, color);
 }
コード例 #3
0
ファイル: MemoryGraph.cs プロジェクト: edwinsyarief/Gearset
        void DrawUIView(InternalLabeler labeler)
        {
            DrawBorderLines(Color.Gray, _memoryMonitor.LineDrawer);
            GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(Position, Position + Size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

            if (ScaleNob.IsMouseOver)
            {
                ScaleNob.DrawBorderLines(Color.Gray);
            }

            labeler.ShowLabel(LabelName.Title, Position + new Vector2(0, -12), "Managed Memory - (allocation per tick in KB)");
        }
コード例 #4
0
ファイル: MemoryGraph.cs プロジェクト: edwinsyarief/Gearset
 static void HideLabels(InternalLabeler labeler)
 {
     labeler.HideLabel(LabelName.Title);
     labeler.HideLabel(LabelName.Gen0Label);
     labeler.HideLabel(LabelName.Gen0);
     labeler.HideLabel(LabelName.Gen1Label);
     labeler.HideLabel(LabelName.Gen1);
     labeler.HideLabel(LabelName.Gen2Label);
     labeler.HideLabel(LabelName.Gen2);
     labeler.HideLabel(LabelName.XboxLabel);
     labeler.HideLabel(LabelName.Xbox);
     labeler.HideLabel(LabelName.MinYAxis);
     labeler.HideLabel(LabelName.MaxYAxis);
 }
コード例 #5
0
ファイル: Plotter.cs プロジェクト: bartwe/Gearset
 public Plotter()
     : base(GearsetResources.Console.Settings.PlotterConfig)
 {
     #if WINDOWS
     _plots = new ObservableCollection<Plot>();
     #else
     plots = new List<Plot>();
     #endif
     Config.Cleared += Config_Cleared;
     // Create the line drawer
     _lines = new InternalLineDrawer();
     Children.Add(_lines);
     _labels = new InternalLabeler();
     Children.Add(_labels);
 }
コード例 #6
0
        public Plotter()
            : base(GearsetResources.Console.Settings.PlotterConfig)
        {
#if WINDOWS
            _plots = new ObservableCollection <Plot>();
#else
            plots = new List <Plot>();
#endif
            Config.Cleared += Config_Cleared;
            // Create the line drawer
            _lines = new InternalLineDrawer();
            Children.Add(_lines);
            _labels = new InternalLabeler();
            Children.Add(_labels);
        }
コード例 #7
0
ファイル: MemoryGraph.cs プロジェクト: edwinsyarief/Gearset
        /// <summary>
        /// //Draw an item on the legend.
        /// </summary>
        /// <param name="labeler"></param>
        /// <param name="position"></param>
        void DrawLegend(InternalLabeler labeler, Vector2 position)
        {
            var offset = new Vector2(0, 15);

            var currentFrame = _memoryMonitor.CurrentFrame;

            DrawLegendItem(labeler, position, LabelName.Gen0Label, LabelName.Gen0, "Gen0", currentFrame.Gen0CollectionCount, FlatTheme.Emerald);

            position += offset;
            DrawLegendItem(labeler, position, LabelName.Gen1Label, LabelName.Gen1, "Gen1", currentFrame.Gen1CollectionCount, FlatTheme.Carrot);

            position += offset;
            DrawLegendItem(labeler, position, LabelName.Gen2Label, LabelName.Gen2, "Gen2", currentFrame.Gen2CollectionCount, FlatTheme.Pomegrantate);

            position += offset;
            DrawLegendItem(labeler, position, LabelName.XboxLabel, LabelName.Xbox, "Xbox", _memoryMonitor.Xbox360CollectionCount, FlatTheme.Silver);
        }
コード例 #8
0
ファイル: MemoryGraph.cs プロジェクト: edwinsyarief/Gearset
        void PlotTickMemoryGraph(InternalLabeler labeler, float graphWidth)
        {
            _plot.Sampler.Values.Clear();
            _plot.Position = new Vector2(Position.X + LegendWidth, Position.Y);
            _plot.Size     = new Vector2(graphWidth, Size.Y);

            var i  = 0;
            var id = _memoryMonitor.FrameId;

            while (i < MemoryMonitor.MaxFrames)
            {
                id++;
                if (id == MemoryMonitor.MaxFrames)
                {
                    id = 0;
                }

                //Display Kilobytes per tick
                _plot.Sampler.Values.Enqueue(_memoryMonitor.Frames[id].TickMemoryBytes / 1024.0f);
                i++;
            }

            labeler.ShowLabel(LabelName.MinYAxis, Position + new Vector2(2 + LegendWidth, Size.Y - 12), "0", Color.White);

            _stringBuilder.SetText(_maxTotalYScaleMb).Append(" MB");
            labeler.ShowLabelEx(LabelName.MaxYAxis, Position + new Vector2(2 + LegendWidth, 0), _stringBuilder, Color.White);

            float actualmin, actualmax;

            _plot.Sampler.GetLimits(out actualmin, out actualmax);

            var min = _plot.Min = _plot.Min + (actualmin - _plot.Min) * 0.3f;
            var max = _plot.Max = _plot.Max + (actualmax - _plot.Max) * 0.3f;

            GearsetResources.Console.Plotter.PlotGraph(_plot, _memoryMonitor.LineDrawer, labeler, MemoryMonitor.MaxFrames, min, max, _plot.Position, _plot.Size, actualmin, actualmax, Size.X - LegendWidth - 40.0f);
        }
コード例 #9
0
        internal void Draw(InternalLabeler labeler, ProfilerManager.FrameLog frameLog)
        {
            if (GearsetResources.CurrentRenderPass != RenderPass.BasicEffectPass)
            {
                return;
            }

            if (frameLog == null || Visible == false || Config.PerformanceGraphConfig.VisibleLevelsFlags == 0)
            {
                labeler.HideLabel("__performanceGraph");
                return;
            }

            DrawBorderLines(Color.Gray, Profiler.LineDrawer);
            GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(Position, Position + Size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

            if (ScaleNob.IsMouseOver)
            {
                ScaleNob.DrawBorderLines(Color.Gray);
            }

            labeler.ShowLabel("__performanceGraph", Position + new Vector2(0, -12), "Performance Graph");

            FrameCounter++;
            if (FrameCounter > SkipFrames)
            {
                FrameCounter = 0;

                //If the frame buffer has capacity will just create a new one; otherwise we'll pop the oldest off and use that.
                Frame frame;
                if (_frames.Count == MaxFrames)
                {
                    frame = _frames.Dequeue();
                    frame.TimingInfos.Clear();
                }
                else
                {
                    frame = new Frame();
                }

                _frames.Enqueue(frame);

                //Populate the frame metrics
                for (var barId = 0; barId < frameLog.Levels.Length; barId++)
                {
                    var bar = frameLog.Levels[barId];
                    for (var j = 0; j < bar.MarkCount; ++j)
                    {
                        frame.TimingInfos.Add(new TimingInfo(
                                                  barId,
                                                  bar.Markers[j].BeginTime,
                                                  bar.Markers[j].EndTime,
                                                  bar.Markers[j].Color));
                    }
                }
            }

            const float frameSpan = 1.0f / 60.0f * 1000f;

            var msToPs = Height / frameSpan;

            //Only render the actual number of frames we are capturing - we may have space for e.g. 120 (2 seconds) but the user is only viewing 60 (1 second)
            var barWidth   = Width / DisplayedFrameCount;
            var graphFloor = Position.Y + Size.Y;
            var position   = new Vector2(Position.X, graphFloor);

            var s = new Vector2(barWidth, msToPs);

            //Set a pointer to the first frame to renders
            var frameId = MaxFrames - DisplayedFrameCount;

            foreach (var frame in _frames)
            {
                //Bail when we have drawn enough
                if (frameId >= MaxFrames)
                {
                    break;
                }

                frameId++;

                foreach (var timeInfo in frame.TimingInfos)
                {
                    if (IsVisibleLevelsFlagSet(timeInfo.Level) == false)
                    {
                        continue;
                    }

                    var durationMilliseconds = timeInfo.EndMilliseconds - timeInfo.StartMilliseconds;
                    if (durationMilliseconds <= 0)
                    {
                        continue;
                    }

                    s.Y        = -durationMilliseconds * msToPs;
                    position.Y = graphFloor - (timeInfo.StartMilliseconds * msToPs);

                    Profiler.TempBoxDrawer.ShowGradientBoxOnce(position, position + s, timeInfo.Color, timeInfo.Color);
                }

                position.X += barWidth;
            }
        }
コード例 #10
0
ファイル: ProfilerSummary.cs プロジェクト: bartwe/Gearset
        internal void Draw(InternalLabeler labeler, Profiler.FrameLog frameLog)
        {
            if (Visible == false || Config.ProfilerSummaryConfig.VisibleLevelsFlags == 0) {
                labeler.HideLabel("__profilerSummary");
                return;
            }

            var font = GearsetResources.Font;

            // Generate log string.
            _logString.Length = 0;
            _logStringTimings.Length = 0;
            foreach (var markerInfo in Profiler.Markers) {
                for (var i = 0; i < Profiler.MaxLevels; ++i) {
                    if (!markerInfo.Logs[i].Initialized)
                        continue;

                    if (Levels[i].Enabled == false)
                        continue;

                    if (_logString.Length > 0) {
                        _logString.Append("\n");
                        _logStringTimings.Append("\n");
                    }

                    _logString.Append(" Level ");
                    _logString.AppendNumber(i);

                    _logString.Append(" ");

                    //Indent!
                    for (var x = 0; x < i; x++)
                        _logString.Append("--");

                    _logString.Append(markerInfo.Name);

                    //_logStringTimings.Append(" Avg.:");
                    _logStringTimings.AppendNumber(markerInfo.Logs[i].SnapAvg);
                    _logStringTimings.Append(" ms ");
                }
            }

            var namesSize = font.MeasureString(_logString);
            var timingsSize = font.MeasureString(_logStringTimings);
            Size = namesSize + new Vector2(timingsSize.X, 0) + new Vector2(Padding * 5, Padding * 2);

            if (GearsetResources.CurrentRenderPass == RenderPass.BasicEffectPass) {
                DrawBorderLines(Color.Gray);
                GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(Position, Position + Size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

                //Fixed size based on summary contrents
                //if (ScaleNob.IsMouseOver)
                //    ScaleNob.DrawBorderLines(Color.Gray);

                labeler.ShowLabel("__profilerSummary", Position + new Vector2(0, -12), "Profiler Summary");

                // Draw log color boxes.
                var position = Position;
                position += new Vector2(Padding);

                foreach (var markerInfo in Profiler.Markers) {
                    for (var i = 0; i < Profiler.MaxLevels; ++i) {
                        if (Levels[i].Enabled == false)
                            continue;

                        if (markerInfo.Logs[i].Initialized == false)
                            continue;

                        Profiler.TempBoxDrawer.ShowGradientBoxOnce(position, position + new Vector2(10), markerInfo.Logs[i].Color, markerInfo.Logs[i].Color);

                        position.Y += font.LineSpacing;
                    }
                }
            }

            if (GearsetResources.CurrentRenderPass == RenderPass.SpriteBatchPass) {
                // Draw log string.
                var position = Position;
                position += new Vector2(Padding * 3, Padding);
                GearsetResources.SpriteBatch.DrawString(font, _logString, position, new Color(180, 180, 180));

                position = Position;
                position += new Vector2(namesSize.X + (Padding * 5), Padding);
                GearsetResources.SpriteBatch.DrawString(font, _logStringTimings, position, new Color(220, 220, 220));
            }
        }
コード例 #11
0
ファイル: PerformanceGraph.cs プロジェクト: bartwe/Gearset
        internal void Draw(InternalLabeler labeler, Profiler.FrameLog frameLog)
        {
            if (GearsetResources.CurrentRenderPass != RenderPass.BasicEffectPass)
                return;

            if (Visible == false || Config.PerformanceGraphConfig.VisibleLevelsFlags == 0) {
                labeler.HideLabel("__performanceGraph");
                return;
            }

            DrawBorderLines(Color.Gray);
            GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(Position, Position + Size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

            if (ScaleNob.IsMouseOver)
                ScaleNob.DrawBorderLines(Color.Gray);

            labeler.ShowLabel("__performanceGraph", Position + new Vector2(0, -12), "Performance Graph");

            _frameCounter++;
            if (_frameCounter > SkipFrames) {
                _frameCounter = 0;

                //If the frame buffer has capacity will just create a new one; otherwise we'll pop the oldest off and use that.
                Frame frame;
                if (_frames.Count == MaxFrames) {
                    frame = _frames.Dequeue();
                    frame.TimingInfos.Clear();
                }
                else
                    frame = new Frame();

                _frames.Enqueue(frame);

                //Populate the frame metrics
                for (var barId = 0; barId < frameLog.Levels.Length; barId++) {
                    var bar = frameLog.Levels[barId];
                    for (var j = 0; j < bar.MarkCount; ++j) {
                        frame.TimingInfos.Add(new TimingInfo(
                            barId,
                            bar.Markers[j].BeginTime,
                            bar.Markers[j].EndTime,
                            bar.Markers[j].Color));
                    }
                }
            }

            const float frameSpan = 1.0f / 60.0f * 1000f;

            var msToPs = Height / frameSpan;

            //Only render the actual number of frames we are capturing - we may have space for e.g. 120 (2 seconds) but the user is only viewing 60 (1 second)
            var barWidth = Width / DisplayedFrameCount;
            var graphFloor = Position.Y + Size.Y;
            var position = new Vector2(Position.X, graphFloor);

            var s = new Vector2(barWidth, msToPs);

            //Set a pointer to the first frame to renders
            var frameId = MaxFrames - DisplayedFrameCount;
            foreach (var frame in _frames) {
                //Bail when we have drawn enough
                if (frameId >= MaxFrames)
                    break;

                frameId++;

                foreach (var timeInfo in frame.TimingInfos) {
                    if (Levels[timeInfo.Level].Enabled == false)
                        continue;

                    var durationMilliseconds = timeInfo.EndMilliseconds - timeInfo.StartMilliseconds;
                    if (durationMilliseconds <= 0)
                        continue;

                    s.Y = -durationMilliseconds * msToPs;
                    position.Y = graphFloor - (timeInfo.StartMilliseconds * msToPs);

                    Profiler.TempBoxDrawer.ShowGradientBoxOnce(position, position + s, timeInfo.Color, timeInfo.Color);
                }

                position.X += barWidth;
            }
        }
コード例 #12
0
        internal void Draw(InternalLabeler labeler, ProfilerManager.FrameLog frameLog)
        {
            if (frameLog == null || Visible == false || Config.ProfilerSummaryConfig.VisibleLevelsFlags == 0)
            {
                labeler.HideLabel("__profilerSummary");
                return;
            }

            var font = GearsetResources.Font;

            // Generate log string.
            _logString.Length        = 0;
            _logStringTimings.Length = 0;

            foreach (var markerInfo in Profiler.Markers)
            {
                for (var i = 0; i < ProfilerManager.MaxLevels; ++i)
                {
                    if (!markerInfo.Logs[i].Initialized)
                    {
                        continue;
                    }

                    if (IsVisibleLevelsFlagSet(i) == false)
                    {
                        continue;
                    }

                    if (_logString.Length > 0)
                    {
                        _logString.Append("\n");
                        _logStringTimings.Append("\n");
                    }

                    _logString.Append(" Level ");
                    _logString.AppendNumber(i);

                    _logString.Append(" ");

                    //Indent!
                    for (var x = 0; x < i; x++)
                    {
                        _logString.Append("--");
                    }

                    _logString.Append(markerInfo.Name);

                    //_logStringTimings.Append(" Avg.:");
                    _logStringTimings.AppendNumber(markerInfo.Logs[i].SnapAvg);
                    _logStringTimings.Append(" ms ");
                }
            }

            var namesSize   = font.MeasureString(_logString);
            var timingsSize = font.MeasureString(_logStringTimings);

            Size = namesSize + new Vector2(timingsSize.X, 0) + new Vector2(Padding * 5, Padding * 2);

            if (GearsetResources.CurrentRenderPass == RenderPass.BasicEffectPass)
            {
                DrawBorderLines(Color.Gray, Profiler.LineDrawer);
                GearsetResources.Console.SolidBoxDrawer.ShowGradientBoxOnce(Position, Position + Size, new Color(56, 56, 56, 150), new Color(16, 16, 16, 127));

                //Fixed size based on summary contrents
                //if (ScaleNob.IsMouseOver)
                //    ScaleNob.DrawBorderLines(Color.Gray);

                labeler.ShowLabel("__profilerSummary", Position + new Vector2(0, -12), "Profiler Summary");

                // Draw log color boxes.
                var position = Position;
                position += new Vector2(Padding);

                foreach (var markerInfo in Profiler.Markers)
                {
                    for (var i = 0; i < ProfilerManager.MaxLevels; ++i)
                    {
                        if (IsVisibleLevelsFlagSet(i) == false)
                        {
                            continue;
                        }

                        if (markerInfo.Logs[i].Initialized == false)
                        {
                            continue;
                        }

                        Profiler.TempBoxDrawer.ShowGradientBoxOnce(position, position + new Vector2(10), markerInfo.Logs[i].Color, markerInfo.Logs[i].Color);

                        position.Y += font.LineSpacing;
                    }
                }
            }

            if (GearsetResources.CurrentRenderPass == RenderPass.SpriteBatchPass)
            {
                // Draw log string.
                var position = Position;
                position += new Vector2(Padding * 3, Padding);
                GearsetResources.SpriteBatch.DrawString(font, _logString, position, new Color(180, 180, 180));

                position  = Position;
                position += new Vector2(namesSize.X + (Padding * 5), Padding);
                GearsetResources.SpriteBatch.DrawString(font, _logStringTimings, position, new Color(220, 220, 220));
            }
        }