def a(): gevent.sleep(0.1) burn_io(0.1) gevent.sleep(0.1) burn_io(0.1) gevent.sleep(0.1) burn_cpu(0.3)
def recursive_a(n): if not n: return burn_io(0.3) gevent.sleep(0.3) g = gevent.spawn(recursive_a, n - 1) return g.get()
def a(): yield from async_sleep(0.1) burn_io(0.1) yield from async_sleep(0.1) burn_io(0.1) yield from async_sleep(0.1) burn_cpu(0.3)
def a(): burn_io_gevent(0.1) burn_io(0.1) burn_io_gevent(0.1) burn_io(0.1) burn_io_gevent(0.1) burn_cpu(0.3)
def common(): for _ in range(100): burn_io_gevent(0.001) burn_io(0.1) burn_cpu(0.2) for _ in range(100): burn_io_gevent(0.001) burn_io(0.1) burn_cpu(0.2)
def test_simple_tagging(self): def tag_cbk(): return 1 def tag_cbk2(): return 2 # test cpu-time yappi.set_tag_callback(tag_cbk) yappi.start() burn_cpu(0.1) yappi.set_tag_callback(tag_cbk2) burn_cpu(0.1) yappi.stop() traces = yappi.get_func_stats() t1 = ''' ../yappi/tests/utils.py:125 burn_cpu 2 0.000000 0.200156 0.100078 ''' self.assert_traces_almost_equal(t1, traces) tagged_traces = yappi.get_func_stats(filter={'tag': 1}) t1 = ''' ../yappi/tests/utils.py:125 burn_cpu 1 0.000000 0.100062 0.100062 ''' self.assert_traces_almost_equal(t1, tagged_traces) yappi.clear_stats() # test wall yappi.set_clock_type("wall") yappi.set_tag_callback(tag_cbk) yappi.start() burn_io(0.1) yappi.set_tag_callback(tag_cbk2) burn_io(0.1) yappi.stop() traces = yappi.get_func_stats() t1 = ''' ..p/yappi/tests/utils.py:134 burn_io 2 0.000000 0.208146 0.104073 ''' self.assert_traces_almost_equal(t1, traces) tagged_traces = yappi.get_func_stats(filter={'tag': 2}) t1 = ''' ..p/yappi/tests/utils.py:134 burn_io 1 0.000000 0.105063 0.105063 ''' self.assert_traces_almost_equal(t1, tagged_traces) yappi.clear_stats()
def a(tag): tlocal._tag = tag burn_io(0.1)
def a(): burn_io(0.1)
def recursive_a(n): if not n: return burn_io(0.1) yield from async_sleep(0.1) yield from recursive_a(n - 1)