Пример #1
0
 def testCompressHistogram_uglyHistogram(self):
     bps = (0, 668, 1587, 3085, 5000, 6915, 8413, 9332, 10000)
     histogram_values = ea.HistogramValue(
         min=0.0,
         max=1.0,
         num=960.0,
         sum=64.0,
         sum_squares=64.0,
         bucket_limit=[
             0.0, 1e-12, 0.917246389039776, 1.0089710279437536,
             1.7976931348623157e+308
         ],
         bucket=[0.0, 896.0, 0.0, 64.0, 0.0])
     histogram_event = ea.HistogramEvent(0, 0, histogram_values)
     compressed_event = ea._CompressHistogram(histogram_event, bps)
     vals = compressed_event.compressed_histogram_values
     self.assertEquals(tuple(v.basis_point for v in vals), bps)
     self.assertAlmostEqual(vals[0].value, 0.0)
     self.assertAlmostEqual(vals[1].value, 7.157142857142856e-14)
     self.assertAlmostEqual(vals[2].value, 1.7003571428571426e-13)
     self.assertAlmostEqual(vals[3].value, 3.305357142857143e-13)
     self.assertAlmostEqual(vals[4].value, 5.357142857142857e-13)
     self.assertAlmostEqual(vals[5].value, 7.408928571428571e-13)
     self.assertAlmostEqual(vals[6].value, 9.013928571428571e-13)
     self.assertAlmostEqual(vals[7].value, 9.998571428571429e-13)
     self.assertAlmostEqual(vals[8].value, 1.0)
Пример #2
0
    def testHistograms(self):
        """Tests whether histograms are inserted into EventAccumulator."""
        gen = _EventGenerator(self)
        acc = ea.EventAccumulator(gen)

        val1 = ea.HistogramValue(min=1,
                                 max=2,
                                 num=3,
                                 sum=4,
                                 sum_squares=5,
                                 bucket_limit=[1, 2, 3],
                                 bucket=[0, 3, 0])
        val2 = ea.HistogramValue(min=-2,
                                 max=3,
                                 num=4,
                                 sum=5,
                                 sum_squares=6,
                                 bucket_limit=[2, 3, 4],
                                 bucket=[1, 3, 0])

        hst1 = ea.HistogramEvent(wall_time=1, step=10, histogram_value=val1)
        hst2 = ea.HistogramEvent(wall_time=2, step=12, histogram_value=val2)
        gen.AddHistogram('hst1',
                         wall_time=1,
                         step=10,
                         hmin=1,
                         hmax=2,
                         hnum=3,
                         hsum=4,
                         hsum_squares=5,
                         hbucket_limit=[1, 2, 3],
                         hbucket=[0, 3, 0])
        gen.AddHistogram('hst2',
                         wall_time=2,
                         step=12,
                         hmin=-2,
                         hmax=3,
                         hnum=4,
                         hsum=5,
                         hsum_squares=6,
                         hbucket_limit=[2, 3, 4],
                         hbucket=[1, 3, 0])
        acc.Reload()
        self.assertEqual(acc.Histograms('hst1'), [hst1])
        self.assertEqual(acc.Histograms('hst2'), [hst2])