def foo(): with region('a'): for i in iter_proxy([1, 2, 3], 'iter'): with region('b'): pass with region('b'): pass
def foo(): time.sleep(0.02) with region('a'): time.sleep(0.02) for i in iter_proxy(slow_iter([0.1, 0.2, 0.3]), 'iter'): with region('b'): time.sleep(i)
def foo(): with region("a"): for i in iter_proxy([1, 2, 3], "iter"): with region("b"): pass with region("b"): pass
def foo(): time.sleep(0.02) with region("a"): time.sleep(0.02) for i in iter_proxy(slow_iter([0.1, 0.2, 0.3]), "iter"): with region("b"): time.sleep(i)
def g_demo_heir(): for ii in range(2): # call via "decorated" global rp instance rp.func()(demo_hand_decorated)() demo_global_context_mgr() demo_global_function_decorator() for ii in rp.iter_proxy(slow_iter(range(2)), slow_iter.__name__): pass
def bar(): with region('init'): # measure execution time of the next block a = np.arange(1000000) print('A initialized') with region('init'): # Join region b = a.copy('') with region('loop'): for x in iter_proxy(slow_iter([1, 2, 3, 4]), 'iter'): # measure time to retrieve next element a += x with region(): # autoname region return np.sum(a * b)
def bar(): with region('a'): with region('bar_global', asglobal=True): for i in iter_proxy([1, 2, 3], 'iter', asglobal=True): pass
def foo(): with region(): for i in iter_proxy([1, 2, 3]): pass
def bar(): with region("a"): with region("bar_global", asglobal=True): for i in iter_proxy([1, 2, 3], "iter", asglobal=True): pass