Esempio n. 1
0
        void ReadResults(XmlNode?node, List <RunResults> results)
        {
            if (node == null)
            {
                return;
            }

            foreach (XmlNode?resultNode in node.SelectNodes("./result"))
            {
                if (resultNode == null)
                {
                    continue;
                }

                var result = new RunResults(this)
                {
                    NativeToManaged = ReadDecimalAttribute(resultNode, "nativeToManaged"),
                    TotalInit       = ReadDecimalAttribute(resultNode, "totalInit"),
                    Displayed       = ReadDecimalAttribute(resultNode, "displayed"),
                };

                XmlNode?log = resultNode.SelectSingleNode("./logcat");
                if (log != null)
                {
                    result.LogcatPath = Utilities.GetAttributeValue(log, "path", String.Empty);
                }
                results.Add(result);
            }
        }
Esempio n. 2
0
        public ReportAverages(RunDefinition run, uint repetitionCount, Action <List <RunResults> > sorter)
        {
            All = new RunResults(run);

            if (repetitionCount >= 2)
            {
                NoSlowest = new RunResults(run);
                if (repetitionCount >= 3)
                {
                    NoOutliers = new RunResults(run);
                }
            }

            Calculate(run, sorter);
        }
Esempio n. 3
0
        void Calculate(RunDefinition run, Action <List <RunResults> >?sorter)
        {
            bool haveOutliers  = NoOutliers != null;
            bool haveNoSlowest = NoSlowest != null;

            var     runResults = new List <RunResults> (run.Results);
            decimal count      = runResults.Count;

            if ((haveOutliers || haveNoSlowest) && sorter != null)
            {
                sorter(runResults);
            }

            for (int i = 0; i < count; i++)
            {
                RunResults results = runResults [i];

                if ((haveOutliers || haveNoSlowest) && i < runResults.Count - 1)
                {
                    if (i > 0)
                    {
                        NoOutliers !.NativeToManaged += results.NativeToManaged / (count - 2);
                        NoOutliers.TotalInit         += results.TotalInit / (count - 2);
                        NoOutliers.Displayed         += results.Displayed / (count - 2);
                    }

                    NoSlowest !.NativeToManaged += results.NativeToManaged / (count - 1);
                    NoSlowest.TotalInit         += results.TotalInit / (count - 1);
                    NoSlowest.Displayed         += results.Displayed / (count - 1);
                }

                All.NativeToManaged += results.NativeToManaged / count;
                All.TotalInit       += results.TotalInit / count;
                All.Displayed       += results.Displayed / count;
            }
        }
Esempio n. 4
0
        void Averages(StreamWriter sw, string title, Project project, List <Column <ReportLinePerformance> > columns, Action <List <RunResults> > sorter)
        {
            sw.WriteLine();
            sw.WriteLine($"### {title}");
            sw.WriteLine();

            var reportLines    = new List <ReportLinePerformance> ();
            var sortedAverages = new List <RunResults> ();

            var reportLinesNoOutliers    = new List <ReportLinePerformance> ();
            var sortedAveragesNoOutliers = new List <RunResults> ();

            var reportLinesNoSlowest    = new List <ReportLinePerformance> ();
            var sortedAveragesNoSlowest = new List <RunResults> ();

            foreach (RunDefinition run in project.Runs)
            {
                var averages = new ReportAverages(run, project.RepetitionCount, sorter);

                sortedAverages.Add(averages.All);
                reportLines.Add(new ReportLinePerformance());

                if (averages.NoOutliers != null)
                {
                    sortedAveragesNoOutliers.Add(averages.NoOutliers);
                    reportLinesNoOutliers.Add(new ReportLinePerformance());
                }

                if (averages.NoSlowest != null)
                {
                    sortedAveragesNoSlowest.Add(averages.NoSlowest);
                    reportLinesNoSlowest.Add(new ReportLinePerformance());
                }
            }

            bool haveOutliers  = sortedAveragesNoOutliers.Count > 0;
            bool haveNoSlowest = sortedAveragesNoSlowest.Count > 0;

            SortAndPrepare(sortedAverages, reportLines);

            if (haveOutliers || haveNoSlowest)
            {
                sw.WriteLine("All runs:");
            }
            WriteTable(sw, reportLines, columns);

            if (haveNoSlowest)
            {
                SortAndPrepare(sortedAveragesNoSlowest, reportLinesNoSlowest);
                sw.WriteLine();
                sw.WriteLine("Slowest run removed:");
                WriteTable(sw, reportLinesNoSlowest, columns);
            }

            if (haveOutliers)
            {
                SortAndPrepare(sortedAveragesNoOutliers, reportLinesNoOutliers);
                sw.WriteLine();
                sw.WriteLine("Slowest and fastest runs removed:");
                WriteTable(sw, reportLinesNoOutliers, columns);
            }

            void SortAndPrepare(List <RunResults> averages, List <ReportLinePerformance> lines)
            {
                sorter(averages);
                for (int i = 0; i < averages.Count; i++)
                {
                    RunResults            average = averages[i];
                    ReportLinePerformance rl      = lines[i];

                    rl.NativeToManaged = ToMilliseconds(average.NativeToManaged);
                    rl.TotalInit       = ToMilliseconds(average.TotalInit);
                    rl.Displayed       = ToMilliseconds(average.Displayed);
                    rl.Notes           = average.Owner.Description;
                }
            }
        }