/// <summary> /// Generate the PerfEventsData from the info provided to the ctor. /// </summary> /// <returns>A new instance of the AggregateEventsData class.</returns> public AggregateEventsData Generate() { using (var eventSource = new ETWTraceEventSource(m_etlFile)) { if (eventSource.EventsLost > 0) Console.WriteLine("WARNING: {0} events were lost during capture.", eventSource.EventsLost); m_aed = new AggregateEventsData(m_testName, Platform.Windows, eventSource.PointerSize == 8 ? Architecture.Amd64 : Architecture.X86); ParseClrTraceEvents(eventSource); ParseKernelTraceEvents(eventSource); // process the stream of events eventSource.Process(); } if (!m_processFound) throw new ArgumentException(string.Format("No data was found for process named {0}. Please ensure the name of the process is correct.", m_process)); return m_aed; }
static AggregateEventsData MegeData(ICollection<AggregateEventsData> eventsData) { if (eventsData == null) throw new ArgumentNullException("eventsData"); // verify that the test and platform values are homogenous string testName = null; Platform? platform = null; Architecture? arch = null; foreach (var eventData in eventsData) { if (testName == null) testName = eventData.TestName; else if (string.Compare(testName, eventData.TestName, StringComparison.OrdinalIgnoreCase) != 0) throw new InvalidOperationException(string.Format("Cannot merge data from different tests '{0}' and '{1}'.", testName, eventData.TestName)); if (platform == null) platform = eventData.Platform; else if (platform.Value != eventData.Platform) throw new InvalidOperationException(string.Format("Cannot merge data from different architectures {0} and {1}.", platform.Value, eventData.Platform)); if (arch == null) arch = eventData.Architecture; else if (arch.Value != eventData.Architecture) throw new InvalidOperationException(string.Format("Cannot merge data from different architectures {0} and {1}.", arch.Value, eventData.Architecture)); } AggregateEventsData mergedEventsData = new AggregateEventsData(testName, platform.Value, arch.Value); var clrEvents = new List<BaseEventData<ClrPerfEvents>>(eventsData.Count); var kernelEvents = new List<BaseEventData<KernelPerfEvents>>(eventsData.Count); foreach (var eventData in eventsData) { foreach (var clrEventData in eventData.ClrEventsData.Values) clrEvents.Add(clrEventData); foreach (var kernelEventData in eventData.KernelEventsData.Values) kernelEvents.Add(kernelEventData); } mergedEventsData.AddData(clrEvents[0].MergeEventData(clrEvents)); mergedEventsData.AddData(kernelEvents[0].MergeEventData(kernelEvents)); return mergedEventsData; }