public void OnMetric(TestId testId, PerformanceMetric metric) { if (m_collectingMetrics) { m_writer.WriteLine(MetricsFileUtil.ToLine(testId, m_startTime, metric)); } }
static internal bool TryRead(String line, out PerformanceMetric metric) { if (!line.StartsWith("#")) { var parts = line.Split(SplitChars, (int)Col.MetricData + 1);//leave the Data bit as it is, including seperator chars if (parts.Length >= (int)Col.MetricData - 1) { //testId = new TestId( // machineId:parts[0], // agentId:parts[1], // threadId:parts[2] //); metric = new PerformanceMetric() { CallId = NullIfEmpty(parts[(int)Col.MetricCallId]), Name = parts[(int)Col.MetricName], Timestamp = DateTime.ParseExact(parts[(int)Col.MetricTImeStamp], DateFormat, null), Value = Double.Parse(parts[(int)Col.MetricValue]), IsError = StringToBool(parts[(int)Col.MetricIsError]), Data = NullIfEmpty(parts[(int)Col.MetricData]) }; return(true); } } //testId = default(TestId); metric = default(PerformanceMetric); return(false); }
internal void SecondPass(PerformanceMetric metric) //to calculate std deviation based on calculated average { if (metric.IsError) { return; } var diffToTheMean = metric.Value - m_mean; m_sumOfDiffToTheMeanSqrd += diffToTheMean * diffToTheMean; }
static internal String ToLine(TestId testId, DateTime testRunStartTime, PerformanceMetric metric) { return(String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", testId.MachineId, testId.AgentId, testId.ThreadId, (metric.Timestamp - testRunStartTime).TotalMilliseconds, metric.CallId ?? "", metric.Name, metric.Timestamp.ToString(DateFormat), metric.Value, metric.IsError?"t":"f", metric.Data ?? "" )); }
public override void InvokeTest(IPerformanceTestListener testListener) { testListener.OnMetric(PerformanceMetric.NameValue("metric1", 0)); Thread.Sleep(1); testListener.OnMetric(PerformanceMetric.NameValue("metric1", 5)); Thread.Sleep(1); testListener.OnMetric(PerformanceMetric.NameValue("metric1", 4)); Thread.Sleep(3); testListener.OnMetric(PerformanceMetric.NameValue("metric1", 10)); testListener.OnMetric(PerformanceMetric.NameValue("metricIgnored", 10)); testListener.OnMetric(new PerformanceMetric { Name = "metric1", IsError = true }); //should be ignored testListener.OnMetric(new PerformanceMetric { Name = "metricIgnored2", IsError = true }); //single metric with error,average calcs shouldn't bail }
internal void FirstPass(PerformanceMetric metric) //to calculate average { if (metric.IsError) { m_errorCount++; return; } m_validCount++; if (m_min > metric.Value) { m_min = metric.Value; } if (m_max < metric.Value) { m_max = metric.Value; } //loss a bit of precision but it prevents overflow if a huge number of metrics m_mean += (metric.Value - m_mean) / m_validCount; }
internal void SecondPass(PerformanceMetric metric) //to calculate std deviation based on calculated average { if (metric.IsError) { return; } var diffToTheMean = metric.Value - m_mean; m_sumOfDiffToTheMeanSqrd += diffToTheMean*diffToTheMean; }
internal void FirstPass(PerformanceMetric metric) //to calculate average { if (metric.IsError) { m_errorCount++; return; } m_validCount++; if (m_min > metric.Value) { m_min = metric.Value; } if (m_max < metric.Value) { m_max = metric.Value; } //loss a bit of precision but it prevents overflow if a huge number of metrics m_mean += (metric.Value - m_mean)/m_validCount; }
internal static bool TryRead(string line, out PerformanceMetric metric) { if (!line.StartsWith("#")) { var parts = line.Split(SplitChars, (int)Col.MetricData + 1); // leave the Data bit as it is, including seperator chars if (parts.Length >= (int)Col.MetricData - 1) { // testId = new TestId( // machineId:parts[0], // agentId:parts[1], // threadId:parts[2] // ); metric = new PerformanceMetric { CallId = NullIfEmpty(parts[(int)Col.MetricCallId]), Name = parts[(int)Col.MetricName], Timestamp = DateTime.ParseExact(parts[(int)Col.MetricTImeStamp], DateFormat, null), Value = double.Parse(parts[(int)Col.MetricValue]), IsError = StringToBool(parts[(int)Col.MetricIsError]), Data = NullIfEmpty(parts[(int)Col.MetricData]) }; return true; } } // testId = default(TestId); metric = default(PerformanceMetric); return false; }
internal static string ToLine(TestId testId, DateTime testRunStartTime, PerformanceMetric metric) { return string.Format( "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", testId.MachineId, testId.AgentId, testId.ThreadId, (metric.Timestamp - testRunStartTime).TotalMilliseconds, metric.CallId ?? string.Empty, metric.Name, metric.Timestamp.ToString(DateFormat), metric.Value, metric.IsError ? "t" : "f", metric.Data ?? string.Empty); }
public void OnMetric(PerformanceMetric metric) { m_listener.OnMetric(GetTestId(), metric); }
public void OnMetric(TestId testId, PerformanceMetric metric) { Console.WriteLine(testId + ", " + metric); }