1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
"""
This module benchmarks `GitIgnoreSpec.match_files()` using 1 pattern.
"""
import pytest
from pytest_benchmark.fixture import (
BenchmarkFixture)
from pathspec import (
GitIgnoreSpec)
GROUP = "GitIgnoreSpec.match_files(): 1 line, 6.5k files"
# Hyperscan backend.
@pytest.mark.benchmark(group=GROUP)
def bench_hs_v1(
benchmark: BenchmarkFixture,
cpython_files: str,
cpython_gi_lines_1: list[str],
):
spec = GitIgnoreSpec.from_lines(
cpython_gi_lines_1,
backend='hyperscan',
)
benchmark(run_match, spec, cpython_files)
# Re2 backend.
@pytest.mark.benchmark(group=GROUP)
def bench_re2_v1(
benchmark: BenchmarkFixture,
cpython_files: str,
cpython_gi_lines_1: list[str],
):
spec = GitIgnoreSpec.from_lines(
cpython_gi_lines_1,
backend='re2',
)
benchmark(run_match, spec, cpython_files)
# Simple backend.
@pytest.mark.benchmark(group=GROUP)
def bench_sm_v1(
benchmark: BenchmarkFixture,
cpython_files: str,
cpython_gi_lines_1: list[str],
):
spec = GitIgnoreSpec.from_lines(
cpython_gi_lines_1,
backend='simple',
)
benchmark(run_match, spec, cpython_files)
def run_match(spec: GitIgnoreSpec, files: set[str]):
for _ in spec.match_files(files):
pass
|