def test_fork_wall_time(austin, py, heap): result = austin("-i", "2ms", *heap, *python(py), target("target34.py")) assert py in (result.stderr or result.stdout), result.stderr or result.stdout assert len(processes(result.stdout)) == 1, compress(result.stdout) ts = threads(result.stdout) assert len(ts) == 2, compress(result.stdout) assert has_pattern(result.stdout, "target34.py:keep_cpu_busy:3"), compress(result.stdout) assert not has_pattern(result.stdout, "Unwanted") meta = metadata(result.stdout) assert meta["mode"] == "wall" a = sum_metric(result.stdout) d = int(meta["duration"]) assert 0 < a < 2.1 * d if austin == "austinp": ms = maps(result.stdout) assert len(ms) >= 2, ms assert [_ for _ in ms if "python" in _], ms
def test_fork_cpu_time_idle(py): result = austin("-si", "1ms", *python(py), target("sleepy.py")) assert result.returncode == 0, result.stderr or result.stdout assert has_pattern(result.stdout, "sleepy.py:<module>:"), compress(result.stdout) meta = metadata(result.stdout) a = sum_metric(result.stdout) d = int(meta["duration"]) assert a < 1.1 * d
def test_fork_cpu_time_cpu_bound(py, heap): result = austin("-si", "1ms", *heap, *python(py), target("target34.py")) assert result.returncode == 0, result.stderr or result.stdout assert has_pattern(result.stdout, "target34.py:keep_cpu_busy:3"), compress(result.stdout) assert not has_pattern(result.stdout, "Unwanted") meta = metadata(result.stdout) assert meta["mode"] == "cpu" a = sum_metric(result.stdout) d = int(meta["duration"]) assert 0 < a < 2.1 * d
def test_attach_exposure(py, exposure): with run_python(py, target("sleepy.py"), "3") as p: result = austin("-i", "1ms", "-x", str(exposure), "-p", str(p.pid)) assert result.returncode == 0 assert has_pattern(result.stdout, "sleepy.py:<module>:"), compress(result.stdout) meta = metadata(result.stdout) a = sum_metric(result.stdout) d = int(meta["duration"]) assert exposure * 800000 <= d < exposure * 1200000 p.kill()
def test_attach_wall_time(py, mode, mode_meta, heap): with run_python(py, target("sleepy.py")) as p: sleep(0.5) result = austin(mode, f"10ms", *heap, "-p", str(p.pid)) assert result.returncode == 0 ts = threads(result.stdout) assert len(ts) == 1, compress(result.stdout) assert has_pattern(result.stdout, "sleepy.py:<module>:"), compress(result.stdout) meta = metadata(result.stdout) assert meta["mode"] == mode_meta a = sum_metric(result.stdout) d = int(meta["duration"]) assert a <= d
def test_pipe_wall_time(py): interval = 1 result = austin("-Pi", f"{interval}ms", *python(py), target()) assert result.returncode == 0 meta = metadata(result.stdout) assert meta["python"].startswith(py), meta assert meta["mode"] == "wall", meta assert int(meta["duration"]) > 100000, meta assert meta["interval"] == str(interval * 1000), meta assert len(processes(result.stdout)) == 1 ts = threads(result.stdout) assert len(ts) == 2, ts assert has_pattern(result.stdout, "target34.py:keep_cpu_busy:32") assert not has_pattern(result.stdout, "Unwanted") a = sum_metric(result.stdout) d = int(meta["duration"]) assert 0 < 0.8 * d < a < 2.2 * d