示例#1
0
 def GetOrCreateCounter(self, category, name):
   try:
     return self.GetCounter(category, name)
   except ValueError:
     ctr = tracing_counter.Counter(self, category, name)
     self._counters[ctr.full_name] = ctr
     return ctr
 def testMultiCounterUpdateBounds(self):
   ctr = tracing_counter.Counter(
       None, 'testBasicCounter', 'testBasicCounter')
   ctr.series_names = ['value1', 'value2']
   ctr.timestamps = [0, 1, 2, 3, 4, 5, 6, 7]
   ctr.samples = [0, 0,
                  1, 0,
                  1, 1,
                  2, 1.1,
                  3, 0,
                  1, 7,
                  3, 0,
                  3.1, 0.5]
   ctr.FinalizeImport()
   self.assertEqual(8, ctr.max_total)
   self.assertEqual([0, 0,
                     1, 1,
                     1, 2,
                     2, 3.1,
                     3, 3,
                     1, 8,
                     3, 3,
                     3.1, 3.6], ctr.totals)
示例#3
0
 def setUp(self):
   parent = FakeProcess()
   self.counter = counter_module.Counter(parent, 'cat', 'name')