public void Start(string name, string parentCounterName, DateTime startTime) { if (Map.ContainsKey(name)) { TimingData ctr = Map[name]; if (!ctr.Closed) { throw new NotSupportedException("Cannot reopen counter which is not yet closed."); } ctr.Reopen(startTime); } else { Map[name] = new TimingData(name, parentCounterName, startTime); } }
public static SummaryExecutionMap Summarize(IEnumerable <ExecutionMap> maps) { SummaryExecutionMap result = new SummaryExecutionMap(); HashSet <string> perfDatas = new HashSet <string>(); foreach (ExecutionMap map in maps) { foreach (KeyValuePair <string, TimingData> pair in map.Map) { if (!perfDatas.Contains(pair.Key)) { perfDatas.Add(pair.Key); } } } foreach (string perfData in perfDatas) { TimeSpan summaryTime = new TimeSpan(); string parentName = String.Empty; foreach (ExecutionMap executionMap in maps) { if (executionMap.Map.ContainsKey(perfData)) { TimingData pData = executionMap.Map[perfData]; summaryTime += pData.AccumulatedSpan; parentName = pData.ParentName; } } result.SumMap[perfData] = new SummaryPerformanceData() { SummarySpan = summaryTime, Name = perfData, ParentName = parentName }; } return(result); }