/// <summary>Collects info about amounts of data on the input of a tool for one report.</summary>
        protected override void ProcessToolUsageData(StatisticsReport report, ToolUsageData tool)
        {
            int objAmountFromReport = 0;

            // Go through all statisticts of the tool
            foreach (var stat in tool.ExecutorStats)
            {
                // Make regex match in the statistic name to find out if it contains amount of objects of certain type.
                Match dataTypeMatch = Regex.Match(stat.Key, $@"InputData\.Type\.");

                if (!dataTypeMatch.Success)
                {
                    continue;
                }                                             // Skip if it's not about data types.
                objAmountFromReport += int.Parse(stat.Value); // Else get the amount of objects.
            }

            // Exit if there's no input objects here
            if (objAmountFromReport == 0)
            {
                return;
            }

            // If there was no information about average input of this tool before, add a container for it.
            if (!statsAverageData.ContainsKey(tool.ToolName))
            {
                statsAverageData.Add(tool.ToolName, new StatAverageInfo());
            }
            StatAverageInfo averageInfo = statsAverageData[tool.ToolName];

            // Add info to count average
            averageInfo.StatSum += objAmountFromReport;
            averageInfo.ReportsCount++;

            // If there was no information about min/max input of this tool before, add containers for it
            if (!stats.ContainsKey(tool.ToolName))
            {
                stats.Add(tool.ToolName, new Dictionary <string, int>());

                stats[tool.ToolName].Add(minSeriesIdentifier, objAmountFromReport);
                stats[tool.ToolName].Add(maxSeriesIdentifier, objAmountFromReport);
            }
            else
            {
                // Check if current min is greater than this new value and set this value as min if it is
                if (stats[tool.ToolName][minSeriesIdentifier] > objAmountFromReport)
                {
                    stats[tool.ToolName][minSeriesIdentifier] = objAmountFromReport;
                }
                // Check if current max is lower than this new value and set this value as max if it is
                else if (stats[tool.ToolName][maxSeriesIdentifier] < objAmountFromReport)
                {
                    stats[tool.ToolName][maxSeriesIdentifier] = objAmountFromReport;
                }
            }
        }
        /// <summary>Collects tool average open time from a report.</summary>
        protected override void ProcessToolUsageData(StatisticsReport report, ToolUsageData tool)
        {
            // Skip if there's no information about open time
            if (!tool.UIStats.ContainsKey("OpenTime.Avg"))
            {
                return;
            }

            // Else get the info
            float avgTimeFromReport = float.Parse(tool.UIStats["OpenTime.Avg"]);

            // If there was no information about open time of this tool before, add a container for it.
            if (!statsAverageData.ContainsKey(tool.ToolName))
            {
                statsAverageData.Add(tool.ToolName, new StatAverageInfo());
            }
            StatAverageInfo averageInfo = statsAverageData[tool.ToolName];

            // Add info
            averageInfo.StatSum += avgTimeFromReport;
            averageInfo.ReportsCount++;
        }
Пример #3
0
        /// <summary>Does the analysis and returns a result.</summary>
        public override AnalysisResult GetAnalysisResult()
        {
            // Free temporary storages
            stats            = new Dictionary <string, Dictionary <string, int> >();
            statsAverageData = new Dictionary <string, StatAverageInfo>();

            // Go through all tools in all reports and collect statistics sum
            foreach (StatisticsReport report in Filter.FilteredData)
            {
                foreach (ToolUsageData tool in report.ToolsUsed)
                {
                    ProcessToolUsageData(report, tool);
                }
            }

            // Finally calculate average numbers and put them into a storage.
            foreach (var dataGroupKeyValue in statsAverageData)
            {
                string          dataGroupName      = dataGroupKeyValue.Key;
                StatAverageInfo infoToCountAverage = dataGroupKeyValue.Value;

                float statisticAverage = infoToCountAverage.StatSum / infoToCountAverage.ReportsCount;

                if (!stats.ContainsKey(dataGroupName))
                {
                    stats.Add(dataGroupName, new Dictionary <string, int>());
                }
                // Add this new value to the resulting collection
                stats[dataGroupName][AverageStatisticName] = (int)statisticAverage;
            }

            // Place the resulting dictionary inside an AnalysisResult (here it gets converted into a more convenient way of data presentation)
            AnalysisResult result = new AnalysisResult(stats);

            return(result);
        }