Beispiel #1
0
        private void UpdateTableInner(ref ViewRange viewRange)
        {
            if (_events.Count == 0)
            {
                return;
            }
            var data = _events.Get(_mainChart.SelectedSampleIndex);

            if (data == null || data.Length == 0)
            {
                return;
            }

            float totalTimeMs = _mainChart.SelectedSample;

            // Add rows
            var rowColor2 = Style.Current.Background * 1.4f;

            for (int j = 0; j < data.Length; j++)
            {
                var events = data[j].Events;

                for (int i = 0; i < events.Length; i++)
                {
                    var e    = events[i];
                    var time = Math.Max(e.End - e.Start, MinEventTimeMs);

                    // Reject events outside the view range
                    if (viewRange.SkipEvent(ref e))
                    {
                        continue;
                    }

                    // Count sub-events time
                    double subEventsTimeTotal = 0;
                    for (int k = i + 1; k < events.Length; k++)
                    {
                        var sub = events[k];
                        if (sub.Depth == e.Depth + 1)
                        {
                            subEventsTimeTotal += Math.Max(sub.End - sub.Start, MinEventTimeMs);
                        }
                        else if (sub.Depth <= e.Depth)
                        {
                            break;
                        }
                    }

                    var row = new Row
                    {
                        Values = new object[]
                        {
                            // Event
                            e.Name,

                            // Total (%)
                            (int)(time / totalTimeMs * 1000.0f) / 10.0f,

                            // Self (%)
                            (int)((time - subEventsTimeTotal) / time * 1000.0f) / 10.0f,

                            // Time ms
                            (float)((time * 10000.0f) / 10000.0f),

                            // Self ms
                            (float)(((time - subEventsTimeTotal) * 10000.0f) / 10000.0f),
                        },
                        Depth  = e.Depth,
                        Width  = _table.Width,
                        Parent = _table,
                    };

                    if (i % 2 == 0)
                    {
                        row.BackgroundColor = rowColor2;
                    }
                }
            }
        }
Beispiel #2
0
        private float UpdateTimelineInner(ref ViewRange viewRange)
        {
            if (_events.Count == 0)
            {
                return(0);
            }
            var data = _events.Get(_mainChart.SelectedSampleIndex);

            if (data == null || data.Length == 0)
            {
                return(0);
            }

            // Find the first event start time (for the timeline start time)
            double startTime = data[0].Events[0].Start;

            for (int i = 1; i < data.Length; i++)
            {
                startTime = Math.Min(startTime, data[i].Events[0].Start);
            }

            var container = _timeline.EventsContainer;

            // Create timeline track per thread
            int depthOffset = 0;

            for (int i = 0; i < data.Length; i++)
            {
                var events = data[i].Events;

                // Check maximum depth
                int maxDepth = -1;
                for (int j = 0; j < events.Length; j++)
                {
                    var e = events[j];

                    // Reject events outside the view range
                    if (viewRange.SkipEvent(ref e))
                    {
                        continue;
                    }

                    maxDepth = Mathf.Max(maxDepth, e.Depth);
                }

                // Skip empty tracks
                if (maxDepth == -1)
                {
                    continue;
                }

                // Add thread label
                float xOffset = 90;
                var   label   = new Timeline.TrackLabel
                {
                    Bounds          = new Rectangle(0, depthOffset * Timeline.Event.DefaultHeight, xOffset, (maxDepth + 2) * Timeline.Event.DefaultHeight),
                    Name            = data[i].Name,
                    BackgroundColor = Style.Current.Background * 1.1f,
                    Parent          = container,
                };

                // Add events
                for (int j = 0; j < events.Length; j++)
                {
                    var e = events[j];
                    if (e.Depth == 0)
                    {
                        // Reject events outside the view range
                        if (viewRange.SkipEvent(ref e))
                        {
                            continue;
                        }

                        AddEvent(startTime, maxDepth, xOffset, depthOffset, j, events, container);
                    }
                }

                depthOffset += maxDepth + 2;
            }

            return(Timeline.Event.DefaultHeight * depthOffset);
        }