Exemple #1
0
        int ThreadNameSorter(EventsThreadRow a, EventsThreadRow b)
        {
            if (a.Description.ThreadID == ThreadDescription.InvalidThreadID && b.Description.ThreadID != ThreadDescription.InvalidThreadID)
            {
                return(-1);
            }

            if (a.Description.ThreadID != ThreadDescription.InvalidThreadID && b.Description.ThreadID == ThreadDescription.InvalidThreadID)
            {
                return(1);
            }

            int nameCompare = a.Name.CompareTo(b.Name);

            return(nameCompare != 0 ? nameCompare : a.Description.ThreadID.CompareTo(b.Description.ThreadID));
        }
Exemple #2
0
            public bool IsMatch(EventsThreadRow thread)
            {
                // Max distance between thread names
                int maxLevensteinDistance = thread.Description.Name.Length / 3;

                foreach (EventsThreadRow candidate in Threads)
                {
                    if (candidate.Description.Mask == thread.Description.Mask && candidate.Description.Origin == thread.Description.Origin)
                    {
                        if (Utils.ComputeLevenshteinDistance(candidate.Description.Name, thread.Description.Name) < maxLevensteinDistance)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }
        void InitThreadList(SamplingFrame frame)
        {
            Frame = frame;

            List <ThreadRow> rows = new List <ThreadRow>();

            if (frame != null)
            {
                List <Entry> entries = new List <Entry>();

                SamplingNode root = frame.Root;

                BuildEntryList(entries, root, 0.0);

                EventFrame eventFrame = new EventFrame(new FrameHeader()
                {
                    Start = 0, Finish = Durable.MsToTick(root.Duration)
                }, entries, frame.Group);
                ThreadData threadData = new ThreadData(null)
                {
                    Events = new List <EventFrame> {
                        eventFrame
                    }
                };
                EventsThreadRow row = new EventsThreadRow(frame.Group, new ThreadDescription()
                {
                    Name = "Sampling Node"
                }, threadData);
                row.LimitMaxDepth   = false;
                row.EventNodeHover += Row_EventNodeHover;
                rows.Add(row);
                ThreadViewControl.Scroll.ViewUnit.Width = 1.0;
                ThreadViewControl.InitRows(rows, eventFrame.Header);
            }
            else
            {
                ThreadViewControl.InitRows(rows, null);
            }
        }
Exemple #4
0
        void InitThreadList(FrameGroup group)
        {
            rows.Clear();
            id2row.Clear();

            ThreadList.RowDefinitions.Clear();
            ThreadList.Children.Clear();

            if (group == null)
            {
                return;
            }

            rows.Add(new HeaderThreadRow(group)
            {
                GradientTop    = (BroAlternativeBackground as SolidColorBrush).Color,
                GradientBottom = (BroBackground as SolidColorBrush).Color,
                SplitLines     = (BroBackground as SolidColorBrush).Color,
                TextColor      = Colors.Gray
            });

            for (int i = 0; i < Math.Min(group.Board.Threads.Count, group.Threads.Count); ++i)
            {
                ThreadDescription thread = group.Board.Threads[i];
                ThreadData        data   = group.Threads[i];

                bool threadHasData = false;
                if ((data.Callstacks != null && data.Callstacks.Count > 3) ||
                    /*(data.Sync != null && data.Sync.Intervals.Count > 0) || */
                    (data.Events != null && data.Events.Count > 0))

                {
                    threadHasData = true;
                }

                if (threadHasData)
                {
                    EventsThreadRow row = new EventsThreadRow(group, thread, data);
                    rows.Add(row);
                    id2row.Add(i, row);

                    row.EventNodeHover    += Row_EventNodeHover;
                    row.EventNodeSelected += Row_EventNodeSelected;
                }
            }

            scroll.TimeSlice = group.Board.TimeSlice;
            scroll.Height    = 0.0;
            scroll.Width     = surface.ActualWidth * RenderSettings.dpiScaleX;
            rows.ForEach(row => scroll.Height += row.Height);

            rows.ForEach(row => row.BuildMesh(surface, scroll));

            ThreadList.Margin = new Thickness(0, 0, 3, 0);

            double offset = 0.0;

            for (int threadIndex = 0; threadIndex < rows.Count; ++threadIndex)
            {
                ThreadRow row = rows[threadIndex];
                row.Offset = offset;

                ThreadList.RowDefinitions.Add(new RowDefinition());

                Thickness margin = new Thickness(0, 0, 0, 0);

                Label labelName = new Label()
                {
                    Content = row.Name, Margin = margin, Padding = new Thickness(), FontWeight = FontWeights.Bold, Height = row.Height / RenderSettings.dpiScaleY, VerticalContentAlignment = VerticalAlignment.Center
                };

                Grid.SetRow(labelName, threadIndex);

                if (threadIndex % 2 == 1)
                {
                    labelName.Background = BroAlternativeBackground;
                }

                ThreadList.Children.Add(labelName);
                offset += row.Height;
            }

            InitBackgroundMesh();
        }
Exemple #5
0
        List <EventsThreadRow> GenerateThreadRows(FrameGroup group)
        {
            id2row.Clear();

            List <EventsThreadRow> eventThreads = new List <EventsThreadRow>();

            for (int i = 0; i < Math.Min(group.Board.Threads.Count, group.Threads.Count); ++i)
            {
                ThreadData        data   = group.Threads[i];
                ThreadDescription thread = data.Description;

                if (thread.IsIdle)
                {
                    continue;
                }

                bool threadHasData = false;
                if (data.Events != null)
                {
                    double duration = 0.0;
                    foreach (EventFrame frame in data.Events)
                    {
                        duration += frame.Duration;
                        if (duration > MIN_THREAD_ACCUMULATED_DURATION)
                        {
                            threadHasData = true;
                            break;
                        }
                    }
                }

                if (thread.Origin == ThreadDescription.Source.Core)
                {
                    threadHasData = true;
                }

                if (threadHasData)
                {
                    EventsThreadRow row = new EventsThreadRow(group, thread, data);
                    eventThreads.Add(row);

                    id2row.Add(row.Description.ThreadIndex, row);
                    row.EventNodeHover    += Row_EventNodeHover;
                    row.EventNodeSelected += Row_EventNodeSelected;
                }

                if (GenerateSamplingThreads && data.Callstacks != null && data.Callstacks.Count > 3)
                {
                    ThreadData      samplingData = GenerateSamplingThread(group, data);
                    EventsThreadRow row          = new EventsThreadRow(group, new ThreadDescription()
                    {
                        Name = thread.Name + " [Sampling]", Origin = ThreadDescription.Source.Sampling
                    }, samplingData);
                    eventThreads.Add(row);
                    row.EventNodeHover    += Row_EventNodeHover;
                    row.EventNodeSelected += Row_EventNodeSelected;
                }
            }

            return(SortRows(eventThreads));
        }