Example #1
0
        private static IEnumerable <TestIterationResult> ParseOneXmlFile(XDocument doc)
        {
            foreach (var testElem in doc.Descendants("test"))
            {
                var testName = testElem.Attribute("name").Value;

                var perfElem = testElem.Element("performance");
                var runId    = perfElem.Attribute("runid").Value;
                var etlPath  = perfElem.Attribute("etl").Value;

                foreach (var metrics in perfElem.Descendants("metrics"))
                {
                    foreach (var metric in metrics.Elements())
                    {
                        var metricName = metric.Name.LocalName;
                        var unit       = metric.Attribute("unit").Value;

                        //
                        // Populate the set of all collected metrics
                        //
                        if (!Properties.AllMetrics.ContainsKey(metricName))
                        {
                            Properties.AllMetrics.Add(metricName, unit);
                        }
                    }
                }

                foreach (var iteration in perfElem.Descendants("iteration"))
                {
                    var index = int.Parse(iteration.Attribute("index").Value);

                    if (index == 0)
                    {
                        continue;
                    }

                    var result = new TestIterationResult();
                    result.TestName      = testName;
                    result.TestIteration = index;
                    result.RunId         = runId;
                    result.EtlPath       = etlPath;

                    foreach (var metricAttr in iteration.Attributes().Where(a => a.Name != "index"))
                    {
                        var metricName = metricAttr.Name.LocalName;
                        var metricVal  = double.Parse(metricAttr.Value);

                        result.MetricValues.Add(metricName, metricVal);
                    }

                    yield return(result);
                }
            }
        }
Example #2
0
        private static IEnumerable <TestIterationResult> ParseOneXmlFile(string path)
        {
            Console.WriteLine($"Parsing {path}");

            var doc = XDocument.Load(path);

            foreach (var testElem in doc.Descendants("test"))
            {
                var testName = testElem.Attribute("name").Value;

                var perfElem = testElem.Element("performance");
                var runId    = perfElem.Attribute("runid").Value;
                var etlPath  = perfElem.Attribute("etl").Value;

                foreach (var iteration in perfElem.Descendants("iteration"))
                {
                    var index = int.Parse(iteration.Attribute("index").Value);

                    if (index == 0)
                    {
                        continue;
                    }

                    var result = new TestIterationResult();
                    result.TestName      = testName;
                    result.TestIteration = index;
                    result.RunId         = runId;
                    result.EtlPath       = etlPath;

                    foreach (var metricAttr in iteration.Attributes().Where(a => a.Name != "index"))
                    {
                        var metricName = metricAttr.Name.LocalName;
                        var metricVal  = double.Parse(metricAttr.Value);

                        result.MetricValues.Add(metricName, metricVal);
                    }

                    yield return(result);
                }
            }
        }