Beispiel #1
0
def test_gc_on(py):
    result = austin("-gi", "1ms", *python(py), target("target_gc.py"))
    assert result.returncode == 0

    meta = metadata(result.stdout)
    assert float(meta["gc"]) / float(meta["duration"]) > 0.1

    gcs = [_ for _ in samples(result.stdout) if ":GC:" in _]
    assert len(gcs) > 10
Beispiel #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, _
Beispiel #3
0
def test_gc_disabled(py, monkeypatch):
    monkeypatch.setenv("GC_DISABLED", "1")

    result = austin("-gi", "10ms", *python(py), target("target_gc.py"))
    assert result.returncode == 0

    meta = metadata(result.stdout)
    assert int(meta["gc"]) < int(meta["duration"]) / 20

    gcs = [_ for _ in samples(result.stdout) if ":GC:" in _]
    assert len(gcs) < 5
Beispiel #4
0
def test_fork_memory(py):
    result = austin("-mi", "1ms", *python(py), target("target34.py"))
    assert result.returncode == 0, result.stderr or result.stdout

    assert has_pattern(result.stdout, "target34.py:keep_cpu_busy:32")

    meta = metadata(result.stdout)

    assert meta["mode"] == "memory"

    d = int(meta["duration"])
    assert d > 100000

    ms = [int(_.rpartition(" ")[-1]) for _ in samples(result.stdout)]
    alloc = sum(_ for _ in ms if _ > 0)
    dealloc = sum(-_ for _ in ms if _ < 0)

    assert alloc * dealloc
Beispiel #5
0
def test_fork_output(py, tmp_path):
    datafile = tmp_path / "test_fork_output.austin"

    result = austin("-i", "1ms", "-o", datafile, *python(py),
                    target("target34.py"))
    assert result.returncode == 0, result.stderr or result.stdout

    assert "Unwanted" in result.stdout

    with datafile.open() as f:
        data = f.read()
        assert has_pattern(data, "target34.py:keep_cpu_busy:32")

        meta = metadata(data)

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

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

        assert 0 < 0.9 * d < a < 2.1 * d
Beispiel #6
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