Пример #1
0
 def test_rasing_incrementers(self):
     """ use Thread"""
     concurrency = 3  # number of the threads
     number = 10000  # number of counting per thread
     counter_name = "counter"
     timer_name = "seconds"
     start_time = counters._start_timer()
     start_functor(concurrency, number, self.counters.inc, counter_name)
     counters._stop_timer(start_time, self.counters._statistics_data, self.counters._statistics_spec, timer_name)
     self.assertEqual(counters._get_counter(self.counters._statistics_data, counter_name), concurrency * number)
     self.assertGreaterEqual(counters._get_counter(self.counters._statistics_data, timer_name), 0.0)
Пример #2
0
 def test_rasing_incrementers(self):
     """ use Thread"""
     concurrency = 3  # number of the threads
     number = 10000  # number of counting per thread
     counter_name = "counter"
     timer_name = "seconds"
     start_time = counters._start_timer()
     start_functor(concurrency, number, self.counters.inc, counter_name)
     counters._stop_timer(start_time, self.counters._statistics_data,
                          self.counters._statistics_spec, timer_name)
     self.assertEqual(
         counters._get_counter(self.counters._statistics_data,
                               counter_name), concurrency * number)
     self.assertGreaterEqual(
         counters._get_counter(self.counters._statistics_data, timer_name),
         0.0)
Пример #3
0
 def test_timer(self):
     t1 = counters._start_timer()
     t2 = t1 - timedelta(seconds=1)
     self.assertEqual((t1 - t2).seconds, 1)
     elem = {}
     spec = [{"item_name": "time", "item_type": "real", "item_default": 0.0}]
     counters._stop_timer(t2, elem, spec, "time")
     self.assertGreaterEqual(counters._get_counter(elem, "time"), 1.0)
Пример #4
0
 def test_timer(self):
     t1 = counters._start_timer()
     t2 = t1 - timedelta(seconds=1)
     self.assertEqual((t1 - t2).seconds, 1)
     elem = {}
     spec = [{
         'item_name': 'time',
         'item_type': 'real',
         'item_default': 0.0
     }]
     counters._stop_timer(t2, elem, spec, 'time')
     self.assertGreaterEqual(counters._get_counter(elem, 'time'), 1.0)