def test_basic(): def test_g(): time.sleep(0.01) def test_h(): time.sleep(0.02) def test_f(): for i in range(100): test_g() test_h() thread = threading.Thread(target=test_f) thread.daemon = True thread.start() state = create() for i in range(100): time.sleep(0.02) frame = sys._current_frames()[thread.ident] process(frame, None, state) assert state['count'] == 100 d = state while len(d['children']) == 1: d = first(d['children'].values()) assert d['count'] == 100 assert 'test_f' in str(d['description']) g = [c for c in d['children'].values() if 'test_g' in str(c['description'])][0] h = [c for c in d['children'].values() if 'test_h' in str(c['description'])][0] assert g['count'] < h['count'] assert 95 < g['count'] + h['count'] <= 100
def test_basic(): def test_g(): sleep(0.01) def test_h(): sleep(0.02) def test_f(): for i in range(100): test_g() test_h() thread = threading.Thread(target=test_f) thread.daemon = True thread.start() state = create() for i in range(100): sleep(0.02) frame = sys._current_frames()[thread.ident] process(frame, None, state) assert state["count"] == 100 d = state while len(d["children"]) == 1: d = first(d["children"].values()) assert d["count"] == 100 assert "test_f" in str(d["description"]) g = [ c for c in d["children"].values() if "test_g" in str(c["description"]) ][0] h = [ c for c in d["children"].values() if "test_h" in str(c["description"]) ][0] assert g["count"] < h["count"] assert 95 < g["count"] + h["count"] <= 100 pd = plot_data(state) assert len(set(map(len, pd.values()))) == 1 # all same length assert len(set(pd["color"])) > 1 # different colors
def test_basic(): def test_g(): time.sleep(0.01) def test_h(): time.sleep(0.02) def test_f(): for i in range(100): test_g() test_h() thread = threading.Thread(target=test_f) thread.daemon = True thread.start() state = create() for i in range(100): time.sleep(0.02) frame = sys._current_frames()[thread.ident] process(frame, None, state) assert state['count'] == 100 d = state while len(d['children']) == 1: d = first(d['children'].values()) assert d['count'] == 100 assert 'test_f' in str(d['description']) g = [ c for c in d['children'].values() if 'test_g' in str(c['description']) ][0] h = [ c for c in d['children'].values() if 'test_h' in str(c['description']) ][0] assert g['count'] < h['count'] assert 95 < g['count'] + h['count'] <= 100