public static void Update(RiskMetricGeneratedMessage message) { RiskEntry entry; if (Cache.TryGetValue(message.Signature, out entry)) { Logger.Write("updating " + message.Signature + " count =" + message.NodeCount + " time = " + message.AverageTime + " called count = " + message.CalledCount); entry.SetNewData(message.NumberOfTests, message.Found, message.Descriptors, message.RiskMetric, message.NodeCount, message.CalledCount, message.AverageTime, message.AverageTimeUnder, message.TestsScore, message.GraphScore, message.Complexity); } }
public RiskMetricGeneratedMessage GetRiskMetricsFor(string cacheName) { var ret = new RiskMetricGeneratedMessage(); var graph = _minimizer.GetGraphFor(cacheName, false); Logger.WriteDebug("risk graph generated with " + graph.AllNodes().Count() + " nodes " + graph.AllConnections().Count() + " connections."); ret.Signature = cacheName; var root = graph.AllNodes().FirstOrDefault(x => x.IsRootNode); ret.Found = root != null; var profilerEntries = new List<string>(); if (_configuration.AllSettings("mm-ProfilerSetup") == "DONTRUN") { ret.NumberOfTests = graph.AllNodes().Count(x => x.IsTest); graph.AllNodes().Where(x => x.IsTest).ForEach(x => x.MarkAsProfiled()); } else { EnrichGraphWithProfilerInformation(cacheName, graph); profilerEntries = _profilerData.GetTestsFor(cacheName).ToList(); ret.NumberOfTests = profilerEntries.Count; } ret.NodeCount = graph.AllNodes().Count(); Logger.WriteDebug("node count = " + ret.NodeCount + " tests = " + ret.NumberOfTests); if(root != null) { ret.Descriptors = new List<string>(); if (root.TestDescriptors != null) { foreach (var desc in root.TestDescriptors) { ret.Descriptors.Add(desc.TestRunner); } } ret.Complexity = root.Complexity; } var counts = _profilerData.GetCountsAndTimesFor(cacheName); if (counts != null) { ret.AverageTime = counts.AverageTime; ret.CalledCount = counts.TimesCalled; ret.AverageTimeUnder = counts.AverageTimeUnder; } else { Logger.WriteDebug("null for timing counts"); } var testsScore = _coverageClassifier.CalculateRiskFor(graph); var graphScore = _graphPathsClassifier.CalculateRiskFor(graph); ret.RiskMetric = (int)(testsScore * .7m + graphScore * .3m); ret.TestsScore = 100 - testsScore; ret.GraphScore = 100 - graphScore; return ret; }