def test_timing(): t = Timer(list(reversed([1, 2, 3, 4, 5, 6])).pop) t.start_event('x') t.end_event('x') t.start_event('y') t.end_event('y') py.test.raises(AssertionError, "t.end_event('y')") t.start_event('z') py.test.raises(AssertionError, "t.end_event('y')") t.end_event('z') assert t.events == [('x', 1), ('y', 1), ('z', 1)] assert t.ttime() == 5
def __init__(self, setopts=None, default_goal=None, disable=[], exe_name=None, extmod_name=None, config=None, overrides=None): from rpython.config import translationoption self.timer = Timer() SimpleTaskEngine.__init__(self) self.log = log if config is None: config = translationoption.get_combined_translation_config( translating=True) # XXX patch global variable with translation config translationoption._GLOBAL_TRANSLATIONCONFIG = config self.config = config if overrides is not None: self.config.override(overrides) if setopts is not None: self.config.set(**setopts) self.exe_name = exe_name self.extmod_name = extmod_name self.done = {} self.disable(disable) if default_goal: default_goal, = self.backend_select_goals([default_goal]) if default_goal in self._maybe_skip(): default_goal = None self.default_goal = default_goal self.extra_goals = [] self.exposed = [] # expose tasks def expose_task(task, backend_goal=None): if backend_goal is None: backend_goal = task def proc(): return self.proceed(backend_goal) self.exposed.append(task) setattr(self, task, proc) backend, ts = self.get_backend_and_type_system() for task in self.tasks: explicit_task = task if task == 'annotate': expose_task(task) else: task, postfix = task.split('_') if task in ('rtype', 'backendopt', 'llinterpret', 'pyjitpl'): if ts: if ts == postfix: expose_task(task, explicit_task) else: expose_task(explicit_task) elif task in ('source', 'compile', 'run'): if backend: if backend == postfix: expose_task(task, explicit_task) elif ts: if ts == 'lltype': expose_task(explicit_task) else: expose_task(explicit_task)