To figure out Why is this so slow? I wanted to profile my example generation using line_profiler.
However, I can't get it to work. Here's what I tried:
kernprof -m pytest -n 3 tests/test_conv.py --hypothesis-profile default
pytest -m line_profiler -n 3 tests/test_conv.py --hypothesis-profile default
python3 -m line_profiler -m pytest -n 3 tests/test_conv.py --hypothesis-profile default
- https://pypi.org/project/pytest-line-profiler/
None of which worked. The first three failed immediately either not knowing @profile
or pytest or line_profiler IIRC.
How do I get those three to cooperate together? I had high hopes in Nr. 4, however its documentation states you should might want to annotate your test function:
@pytest.mark.line_profile.with_args(f, g)
But my parameters are supplied by hypothesis, so I tried just with
@pytest.mark.line_profile
which did nothing.
I also tried the alternative approach of using the command line:
pytest --line-profile path.to.function_to_be profiled [...]
However, I couldn't figure out what the path.to.function_to_be profiled
was in my case. My test function is residing in tests/test_conv.py
and is named test_padding
. However, neither
pytest -n auto --line-profile test_padding tests/test_conv.py --hypothesis-profile default
nor
pytest -n auto --line-profile test_conv.test_padding tests/test_conv.py --hypothesis-profile default
worked. Both error'd saying they couldn't find that function.
I therefore ask: How?
Installed is (via pip):
pytest
pytest-xdist[psutil]
hypothesis
line_profiler
pytest-line-profiler