• Kirill Smelkov's avatar
    py.bench: Automatically discover benchmarks in test files · ffb40903
    Kirill Smelkov authored
    Since the beginning (9bf03d9c "py.bench: New command to benchmark python
    code similarly to `go test -bench`") py.bench was automatically
    discovering benchmarks in bench_*.py files only. This was inherited from
    wendelin.core which keeps its benchmarks in those files.
    
    However in pygolang, following Go convention(*), we already have several
    benchmarks that reside together with tests in same *_test.py files. And
    currently just running py.bench does not discover them.
    
    -> Let's fix this and teach py.bench to automatically discover
    benchmarks in the test files by default as well.
    
    Pytest's default is to look for tests in test_*.py and *_test.py (+).
    Add those patterns and also keep bench_*.py for backward compatibility.
    
    Before this patch running py.bench inside pygolang repository does not
    run any benchmark at all. After the patch py.bench runs all the
    benchmarks by default:
    
        (z-dev) kirr@deca:~/src/tools/go/pygolang$ py.bench
        =================...
    ffb40903
pybench.py 9.52 KB