def test_basic(self):
        timers = {}
        time = make_timeit(timers)
        with time('a'):
            _ = 1

        self.assertSetEqual(set(timers.keys()), {'a'})
        self.assertEqual(len(timers['a']), 1)
示例#2
0
    def __init__(self, **runopts):
        super(Runnable, self).__init__()

        self.runopts = runopts

        self.timers = defaultdict(list)
        self.timeit = make_timeit(self.timers, prefix=self.name, loglevel=logging.TRACE)

        self.counters = defaultdict(int)
        self.count = make_count(self.counters, prefix=self.name, loglevel=logging.TRACE)
示例#3
0
    def __init__(self, *args, **kwargs):
        super(Runnable, self).__init__(*args, **kwargs)

        self.timers = {}
        self.timeit = make_timeit(self.timers,
                                  prefix=self.name,
                                  loglevel=logging.TRACE)

        self.counters = {}
        self.count = make_count(self.counters,
                                prefix=self.name,
                                loglevel=logging.TRACE)
    def test_nested_timers(self):
        timers = {}
        time = make_timeit(timers)
        with time('a'):
            with time('b'):
                with time('c'):
                    with time('b'):
                        _ = 2 ** 50

        self.assertSetEqual(set(timers.keys()), {'a', 'b', 'c'})
        self.assertEqual(len(timers['a']), 1)
        self.assertEqual(len(timers['b']), 2)
        self.assertEqual(len(timers['c']), 1)