| 1 |
|
| 2 |
from pathlib import ( |
| 3 |
Path) |
| 4 |
|
| 5 |
import pytest |
| 6 |
from pytest_benchmark.fixture import ( |
| 7 |
BenchmarkFixture) |
| 8 |
|
| 9 |
from pathspec.util import ( |
| 10 |
iter_tree_entries, |
| 11 |
iter_tree_files) |
| 12 |
|
| 13 |
|
| 14 |
@pytest.mark.benchmark(group="iter_tree_entries", warmup=True) |
| 15 |
def bench_iter_tree_entries(benchmark: BenchmarkFixture, cpython_dir: Path): |
| 16 |
benchmark(run_iter_tree_entries, cpython_dir) |
| 17 |
|
| 18 |
|
| 19 |
@pytest.mark.benchmark(group="iter_tree_files", warmup=True) |
| 20 |
def bench_iter_tree_files_v0(benchmark: BenchmarkFixture, cpython_dir: Path): |
| 21 |
benchmark(run_iter_tree_files_v0, cpython_dir) |
| 22 |
|
| 23 |
|
| 24 |
@pytest.mark.benchmark(group="iter_tree_files", warmup=True) |
| 25 |
def bench_iter_tree_files_v1(benchmark: BenchmarkFixture, cpython_dir: Path): |
| 26 |
benchmark(run_iter_tree_files_v1, cpython_dir) |
| 27 |
|
| 28 |
|
| 29 |
def run_iter_tree_entries(path: Path): |
| 30 |
for _ in iter_tree_entries(path): |
| 31 |
pass |
| 32 |
|
| 33 |
|
| 34 |
def run_iter_tree_files_v0(path: Path): |
| 35 |
for entry in iter_tree_entries(path): |
| 36 |
if not entry.is_dir(): |
| 37 |
pass |
| 38 |
|
| 39 |
|
| 40 |
def run_iter_tree_files_v1(path: Path): |
| 41 |
for _ in iter_tree_files(path): |
| 42 |
pass |