/// <summary> /// Finds the proper text to be used for a tree node /// </summary> /// <param name="node"> node to find name for </param> /// <returns>name of the node to display on tree </returns> public static string TextSelector(Object node) { if (node is ProxyNode) { node = ((ProxyNode)node).Original; } string text = node switch { Project p => p.Name, Target t => "Target " + t.Name, Folder f => f.Name, ProjectEvaluation pe => pe.Name, Microsoft.Build.Logging.StructuredLogger.Task ta => "Task " + ta.Title + " duration " + ta.DurationText, AddItem a => "Add Item " + a.Name, RemoveItem r => "Remove Item " + r.Name, Item i => i.NameAndEquals + " " + i.ShortenedText, Metadata m => m.NameAndEquals + " " + m.ShortenedValue, EvaluationProfileEntry epe => epe.Title + " " + epe.DurationText + " " + epe.ShortenedElementDescription, Property p => p.NameAndEquals + " " + p.ShortenedValue, Parameter p => p.Name, Message m => m.ShortenedText, Import i => "Import " + i.Name + " " + i.Location, NoImport ni => "NoImport " + ni.Name + " " + ni.Location + " " + ni.Text, Error e => e.ToString(), Warning w => w.ToString(), Note n => n.Text, SourceFile sf => sf.Name, SourceFileLine sfl => sfl.LineNumber + " " + sfl.LineText, ProxyNode pn => pn.TypeName, TimedNode t => t.Name, _ => node.ToString() }; return(text); }
internal TimeBoundBufferManager(int maxSize, TimeSpan maxAge, IExecutorService executor) { this.maxSize = maxSize; this.maxAgeMillis = (long)maxAge.TotalMilliseconds; this.executor = executor; var n = new TimedNode(default(T), long.MinValue); tail = n; Volatile.Write(ref head, n); }
private Block CreateBlock(TimedNode node) { var block = new Block(); block.StartTime = node.StartTime; block.EndTime = node.EndTime; block.Text = node.Name; block.Indent = node.GetParentChainIncludingThis().Count(); block.Node = node; return(block); }
private static void PopulateSpeedscopeData(TimedNode node, uint level, long baseTime, List <string> frames, Dictionary <int, LinkedList <SpeedscopeEvent> > buildNodes) { var startTimestamp = node.StartTime.Ticks - baseTime; var endTimestamp = node.EndTime.Ticks - baseTime; var duration = endTimestamp - startTimestamp; if (startTimestamp >= 0 && duration > 0) // Zero duration has no value for performance analyses and messes up the timeline { var frame = frames.Count; #if DEBUG node.Index = frame; #endif frames.Add(GetFrameName(node)); if (!buildNodes.TryGetValue(node.NodeId, out var events)) { events = new LinkedList <SpeedscopeEvent>(); buildNodes.Add(node.NodeId, events); } insertEvent(events, new SpeedscopeEvent(frame, true, startTimestamp, duration, level)); insertEvent(events, new SpeedscopeEvent(frame, false, endTimestamp, duration, level)); } #if DEBUG else { node.Index = -1; } #endif if (node.HasChildren) { var childLevel = level + (1u << 16) & 0xFFFFu << 16; foreach (var childNode in node.Children) { if (childNode is TimedNode timedChildNode) { PopulateSpeedscopeData(timedChildNode, ++childLevel, baseTime, frames, buildNodes); } } }
public override void AddElement(T element) { var now = executor.Now; var n = new TimedNode(element, now); var t = tail; Volatile.Write(ref t.next, n); tail = n; var h0 = head; var h = h0; int s = size; if (s == maxSize) { h = h.next; } now -= maxAgeMillis; for (;;) { n = Volatile.Read(ref h.next); if (n == null) { break; } if (n.timestamp > now) { break; } h = n; s--; } size = s; if (h0 != h) { Volatile.Write(ref head, h); } }
static void AddPropertiesAndItems(TimedNode root, List <TreeNode> roots) { Folder properties = root.FindChild <Folder>(Strings.Properties); if (properties != null) { roots.Add(properties); } Folder items = root.FindChild <Folder>(Strings.Items); if (items != null) { roots.Add(items); } var reassignments = root.FindChild <TimedNode>(Strings.PropertyReassignmentFolder); if (reassignments != null) { roots.Add(reassignments); } }
public IEnumerable <SearchResult> Search( TimedNode context, string searchText, int maxResults, bool markResultsInTree, CancellationToken cancellationToken) { var roots = new List <TreeNode>(); Build build = context.GetRoot() as Build; Project project = context as Project; if (project != null && build != null) { var projectEvaluation = build.FindEvaluation(project.EvaluationId); if (projectEvaluation != null) { AddPropertiesAndItems(projectEvaluation, roots); } } AddPropertiesAndItems(context, roots);
public void GoToTimedNode(TimedNode node) { TextBlock textblock = null; foreach (TimedNode timedNode in node.GetParentChainIncludingThis().OfType <TimedNode>().Reverse()) { if (TextBlocks.TryGetValue(timedNode, out textblock)) { HighlightTextBlock(textblock, scrollToElement: true); break; } } if (textblock == null && activeTextBlock != null) { if (highlight.Parent is Panel parent) { parent.Children.Remove(highlight); } scrollViewer.ScrollToVerticalOffset(0); scrollViewer.ScrollToHorizontalOffset(0); } }