示例#1
0
        protected virtual Report ReportSumByPrefixRound(IList <TaskStats> taskStats)
        {
            // aggregate by task name and by round
            int reported = 0;

            JCG.LinkedDictionary <string, TaskStats> p2 = new JCG.LinkedDictionary <string, TaskStats>();
            foreach (TaskStats stat1 in taskStats)
            {
                if (stat1.Elapsed >= 0 && stat1.Task.GetName().StartsWith(m_prefix, StringComparison.Ordinal))
                { // only ended tasks with proper name
                    reported++;
                    string name  = stat1.Task.GetName();
                    string rname = stat1.Round + "." + name; // group by round
                    if (!p2.TryGetValue(rname, out TaskStats stat2) || stat2 is null)
                    {
                        stat2 = (TaskStats)stat1.Clone();

                        p2[rname] = stat2;
                    }
                    else
                    {
                        stat2.Add(stat1);
                    }
                }
            }
            // now generate report from secondary list p2
            return(GenPartialReport(reported, p2, taskStats.Count));
        }
        /// <summary>
        /// Report statistics as a string, aggregate for tasks named the same, and from the same round.
        /// </summary>
        /// <param name="taskStats"></param>
        /// <returns>The report.</returns>
        protected virtual Report ReportSumByNameRound(IList <TaskStats> taskStats)
        {
            // aggregate by task name and round
            JCG.LinkedDictionary <string, TaskStats> p2 = new JCG.LinkedDictionary <string, TaskStats>();
            int reported = 0;

            foreach (TaskStats stat1 in taskStats)
            {
                if (stat1.Elapsed >= 0)
                { // consider only tasks that ended
                    reported++;
                    string    name  = stat1.Task.GetName();
                    string    rname = stat1.Round + "." + name; // group by round
                    TaskStats stat2;
                    if (!p2.TryGetValue(rname, out stat2) || stat2 == null)
                    {
                        stat2 = (TaskStats)stat1.Clone();

                        p2[rname] = stat2;
                    }
                    else
                    {
                        stat2.Add(stat1);
                    }
                }
            }
            // now generate report from secondary list p2
            return(GenPartialReport(reported, p2, taskStats.Count));
        }