コード例 #1
0
 public void OnMetric(TestId testId, PerformanceMetric metric)
 {
     if (m_collectingMetrics)
     {
         m_writer.WriteLine(MetricsFileUtil.ToLine(testId, m_startTime, metric));
     }
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 public void OnMetric(TestId testId, PerformanceMetric metric)
 {
     if (m_collectingMetrics)
     {
         m_writer.WriteLine(MetricsFileUtil.ToLine(testId, m_startTime, metric));
     }
 }
コード例 #4
0
            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;
            }
コード例 #5
0
 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 ?? ""
                          ));
 }
コード例 #6
0
            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
            }
コード例 #7
0
            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;
            }
コード例 #8
0
 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;
 }
コード例 #9
0
            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;
            }
コード例 #10
0
            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;
            }
コード例 #11
0
 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);
 }
コード例 #12
0
 public void OnMetric(PerformanceMetric metric)
 {                
     m_listener.OnMetric(GetTestId(), metric);
 }
コード例 #13
0
 public void OnMetric(PerformanceMetric metric)
 {
     m_listener.OnMetric(GetTestId(), metric);
 }
コード例 #14
0
 public void OnMetric(TestId testId, PerformanceMetric metric)
 {
     Console.WriteLine(testId + ", " + metric);
 }