コード例 #1
0
ファイル: counters_test.py プロジェクト: rusingineer/bundy
 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)
コード例 #2
0
ファイル: counters_test.py プロジェクト: rusingineer/bundy
 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
ファイル: counters_test.py プロジェクト: zhangyut/bundy
 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
ファイル: counters_test.py プロジェクト: zhangyut/bundy
 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)