示例#1
0
 def get_state(self, duration):
     '''Run any necessary calculations on the data collected from the logs
     and return a list of metric objects.'''
     metrics = []
     if duration > 0:
         metrics += [MetricObject(counter, self.counts[counter]/duration) for counter in self.counts]
     for time_name in self.times:
         values = self.times[time_name]['values']
         unit = self.times[time_name]['unit']
         metrics.append(MetricObject(time_name+'.mean', stats_helper.find_mean(values), unit))
         metrics.append(MetricObject(time_name+'.median', stats_helper.find_median(values), unit))
         metrics += [MetricObject('%s.%sth_percentile' % (time_name,percentile), stats_helper.find_percentile(values,int(percentile)), unit) for percentile in self.percentiles]
             
     return metrics
示例#2
0
 def test_90th_1_to_15_noncontiguous(self):
     self.assertAlmostEqual(stats_helper.find_percentile([1,2,3,4,5,6,7,8,9,15],90), 9.6)
示例#3
0
 def test_90th_1_to_11(self):
     self.assertEqual(stats_helper.find_percentile([1,2,3,4,5,6,7,8,9,10,11],90), 10)
示例#4
0
 def test_90th_1_minus1(self):
     self.assertEqual(stats_helper.find_percentile([1,-1],90), 0.8)
示例#5
0
 def test_90th_1_2_3(self):
     self.assertEqual(stats_helper.find_percentile([1,2,3],90), 2.8)
示例#6
0
 def test_90th_1_2(self):
     self.assertEqual(stats_helper.find_percentile([1,2],90), 1.9)
示例#7
0
 def test_90th_0(self):
     self.assertEqual(stats_helper.find_percentile([0],90), 0)
示例#8
0
 def test_12th_0_to_9(self):
     self.assertEqual(stats_helper.find_percentile([0,1,2,3,4,5,6,7,8,9],12), 1.08)
示例#9
0
 def test_10th_1_to_3(self):
     self.assertEqual(stats_helper.find_percentile([1,2,3],10), 1.2)
示例#10
0
 def test_10th_0_to_10(self):
     self.assertEqual(stats_helper.find_percentile([0,1,2,3,4,5,6,7,8,9,10],10), 1)
示例#11
0
 def test_max_floats(self):
     self.assertEqual(stats_helper.find_percentile([0,0.1,1.5,100],100), 100)
示例#12
0
 def test_max_0_to_11(self):
     self.assertEqual(stats_helper.find_percentile([0,1,2,3,4,5,6,7,8,9,10,11],100), 11)
示例#13
0
 def test_max_0_to_6(self):
     self.assertEqual(stats_helper.find_percentile([0,1,2,3,4,5,6],100), 6)
示例#14
0
 def test_max_0_to_3(self):
     self.assertEqual(stats_helper.find_percentile([0,1,2,3],100), 3)
示例#15
0
 def test_max_0(self):
     self.assertEqual(stats_helper.find_percentile([0],100), 0)