Exemplo n.º 1
0
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
Exemplo n.º 2
0
def test_accuracy_fast_recursive(py, heap):
    result = austin("-i", "1ms", *heap, *python(py), target("recursive.py"))
    assert result.returncode == 0, result.stderr or result.stdout

    assert has_pattern(result.stdout, "sum_up_to"), compress(result.stdout)
    assert has_pattern(result.stdout, ":INVALID:"), compress(result.stdout)

    for _ in samples(result.stdout):
        if "sum_up_to" in _ and "<module>" in _:
            assert len(_.split(";")) <= 20, _
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
def test_fork_exposure(py, exposure):
    result = austin("-i", "1ms", "-x", str(exposure), *python(py),
                    target("sleepy.py"), "1")
    assert result.returncode == 0, result.stderr or result.stdout

    assert has_pattern(result.stdout,
                       "sleepy.py:<module>:"), compress(result.stdout)

    meta = metadata(result.stdout)

    assert meta["mode"] == "wall"

    d = int(meta["duration"])
    assert 900000 * exposure < d < 1100000 * exposure
Exemplo n.º 6
0
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
Exemplo n.º 7
0
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()
Exemplo n.º 8
0
def test_pipe_wall_time_multiprocess_output(py, tmp_path):
    datafile = tmp_path / "test_pipe.austin"

    result = austin("-CPi", "1ms", "-o", str(datafile), *python(py), target())
    assert result.returncode == 0

    with datafile.open() as f:
        data = f.read()
        meta = metadata(data)

        assert meta, meta
        assert meta["mode"] == "wall", meta
        assert int(meta["duration"]) > 100000, meta
        assert meta["interval"] == "1000", meta
        assert meta["multiprocess"] == "on", meta
        assert meta["python"].startswith(py), meta

        assert has_pattern(data,
                           "target34.py:keep_cpu_busy:32"), compress(data)

        a = sum(int(_.rpartition(" ")[-1]) for _ in samples(data))
        d = int(meta["duration"])

        assert 0 < 0.8 * d < a < 2.2 * d