/// <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); }
public AggregateEventsDataComparer(AggregateEventsData baseline, AggregateEventsData live) { if (baseline == null) { throw new ArgumentNullException("baseline"); } if (live == null) { throw new ArgumentNullException("live"); } // ensure that the data being compared is from the same architecture, platform and test if (string.Compare(baseline.TestName, live.TestName, StringComparison.OrdinalIgnoreCase) != 0) { throw new ArgumentException(string.Format("Cannot compare results across different tests. Baseline is {0} and live is {1}.", baseline.TestName, live.TestName)); } // TODO: there might be cases where cross-platform comparisons make sense if (baseline.Platform != live.Platform) { throw new ArgumentException(string.Format("Cannot compare results across different platforms. Baseline is {0} and live is {1}.", baseline.Platform, live.Platform)); } if (baseline.Architecture != live.Architecture) { throw new ArgumentException(string.Format("Cannot compare results across different architectures. Baseline is {0} and live is {1}.", baseline.Architecture, live.Architecture)); } m_baseline = baseline; m_live = live; }
static int Main(string[] args) { var exitCode = 1; try { var cmdOptions = PowerArgs.Args.Parse <CommandLineOptions>(args); if (string.Compare(cmdOptions.Baseline, cmdOptions.Live, StringComparison.OrdinalIgnoreCase) == 0) { throw new ArgumentException("The values of baseline and live parameters cannot be identical."); } var xmls = new XmlSerializer(typeof(AggregateEventsData)); AggregateEventsData baseline = null; AggregateEventsData live = null; using (StreamReader reader = new StreamReader(cmdOptions.Baseline)) { baseline = (AggregateEventsData)xmls.Deserialize(reader); } using (StreamReader reader = new StreamReader(cmdOptions.Live)) { live = (AggregateEventsData)xmls.Deserialize(reader); } var dataComparer = new AggregateEventsDataComparer(baseline, live); if (dataComparer.CompareResults()) { Console.WriteLine("PASS: perf results are ok"); exitCode = 0; } else { Console.WriteLine("FAIL: perf results out of tolerance"); } } catch (PowerArgs.ArgException ex) { Console.WriteLine(ex.Message); Console.WriteLine(PowerArgs.ArgUsage.GenerateUsageFromTemplate <CommandLineOptions>()); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } return(exitCode); }
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); }