File: bench_gitwildmatch_150p_to_6500f.py

package info (click to toggle)
python-pathspec 1.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,140 kB
  • sloc: python: 9,685; makefile: 14
file content (196 lines) | stat: -rw-r--r-- 4,717 bytes parent folder | download
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
"""
This module benchmarks :class:`.GitWildMatchPattern` using ~150 patterns against
~6.5k files.
"""

import pytest
from pytest_benchmark.fixture import (
	BenchmarkFixture)

from pathspec import (
	GitIgnoreSpec,
	PathSpec)

from benchmarks.gitwildmatch_v1 import (
	GitWildMatchV1Pattern)


GROUP_GITIGNORE = "GitWildMatchPattern: GitIgnore.match_files(): 150 lines, 6.5k files"

GROUP_PATHSPEC = "GitWildMatchPattern: PathSpec.match_files(): 150 lines, 6.5k files"


# # Hyperscan backend.
#
# @pytest.mark.benchmark(group=GROUP_GITIGNORE)
# def bench_hs_gitignore_v1(
# 	benchmark: BenchmarkFixture,
# 	cpython_files: set[str],
# 	cpython_gi_lines_all: list[str],
# ):
# 	spec = GitIgnoreSpec.from_lines(
# 		lines=cpython_gi_lines_all,
# 		pattern_factory=GitWildMatchV1Pattern,
# 		backend='hyperscan',
# 	)
# 	benchmark(run_match, spec, cpython_files)
#
#
# @pytest.mark.benchmark(group=GROUP_GITIGNORE)
# def bench_hs_gitignore_v2(
# 	benchmark: BenchmarkFixture,
# 	cpython_files: set[str],
# 	cpython_gi_lines_all: list[str],
# ):
# 	spec = GitIgnoreSpec.from_lines(
# 		lines=cpython_gi_lines_all,
# 		backend='hyperscan',
# 	)
# 	benchmark(run_match, spec, cpython_files)
#
#
# @pytest.mark.benchmark(group=GROUP_PATHSPEC)
# def bench_hs_pathspec_v1(
# 	benchmark: BenchmarkFixture,
# 	cpython_files: set[str],
# 	cpython_gi_lines_all: list[str],
# ):
# 	spec = PathSpec.from_lines(
# 		lines=cpython_gi_lines_all,
# 		pattern_factory=GitWildMatchV1Pattern,
# 		backend='hyperscan',
# 	)
# 	benchmark(run_match, spec, cpython_files)
#
#
# @pytest.mark.benchmark(group=GROUP_PATHSPEC)
# def bench_hs_pathspec_v2(
# 	benchmark: BenchmarkFixture,
# 	cpython_files: set[str],
# 	cpython_gi_lines_all: list[str],
# ):
# 	spec = PathSpec.from_lines(
# 		lines=cpython_gi_lines_all,
# 		pattern_factory='gitwildmatch',
# 		backend='hyperscan',
# 	)
# 	benchmark(run_match, spec, cpython_files)
#
#
# # Re2 backend.
#
# @pytest.mark.benchmark(group=GROUP_GITIGNORE)
# def bench_re2_gitignore_v1(
# 	benchmark: BenchmarkFixture,
# 	cpython_files: set[str],
# 	cpython_gi_lines_all: list[str],
# ):
# 	spec = GitIgnoreSpec.from_lines(
# 		lines=cpython_gi_lines_all,
# 		pattern_factory=GitWildMatchV1Pattern,
# 		backend='re2',
# 	)
# 	benchmark(run_match, spec, cpython_files)
#
#
# @pytest.mark.benchmark(group=GROUP_GITIGNORE)
# def bench_re2_gitignore_v2(
# 	benchmark: BenchmarkFixture,
# 	cpython_files: set[str],
# 	cpython_gi_lines_all: list[str],
# ):
# 	spec = GitIgnoreSpec.from_lines(
# 		lines=cpython_gi_lines_all,
# 		backend='re2',
# 	)
# 	benchmark(run_match, spec, cpython_files)
#
#
# @pytest.mark.benchmark(group=GROUP_PATHSPEC)
# def bench_re2_pathspec_v1(
# 	benchmark: BenchmarkFixture,
# 	cpython_files: set[str],
# 	cpython_gi_lines_all: list[str],
# ):
# 	spec = PathSpec.from_lines(
# 		lines=cpython_gi_lines_all,
# 		pattern_factory=GitWildMatchV1Pattern,
# 		backend='re2',
# 	)
# 	benchmark(run_match, spec, cpython_files)
#
#
# @pytest.mark.benchmark(group=GROUP_PATHSPEC)
# def bench_re2_pathspec_v2(
# 	benchmark: BenchmarkFixture,
# 	cpython_files: set[str],
# 	cpython_gi_lines_all: list[str],
# ):
# 	spec = PathSpec.from_lines(
# 		lines=cpython_gi_lines_all,
# 		pattern_factory='gitwildmatch',
# 		backend='re2',
# 	)
# 	benchmark(run_match, spec, cpython_files)


# Simple backend.

@pytest.mark.benchmark(group=GROUP_GITIGNORE)
def bench_sm_gitignore_v1(
	benchmark: BenchmarkFixture,
	cpython_files: set[str],
	cpython_gi_lines_all: list[str],
):
	spec = GitIgnoreSpec.from_lines(
		lines=cpython_gi_lines_all,
		pattern_factory=GitWildMatchV1Pattern,
		backend='simple',
	)
	benchmark(run_match, spec, cpython_files)


@pytest.mark.benchmark(group=GROUP_GITIGNORE)
def bench_sm_gitignore_v2(
	benchmark: BenchmarkFixture,
	cpython_files: set[str],
	cpython_gi_lines_all: list[str],
):
	spec = GitIgnoreSpec.from_lines(
		lines=cpython_gi_lines_all,
		backend='simple',
	)
	benchmark(run_match, spec, cpython_files)


@pytest.mark.benchmark(group=GROUP_PATHSPEC)
def bench_sm_pathspec_v1(
	benchmark: BenchmarkFixture,
	cpython_files: set[str],
	cpython_gi_lines_all: list[str],
):
	spec = PathSpec.from_lines(
		lines=cpython_gi_lines_all,
		pattern_factory=GitWildMatchV1Pattern,
		backend='simple',
	)
	benchmark(run_match, spec, cpython_files)


@pytest.mark.benchmark(group=GROUP_PATHSPEC)
def bench_sm_pathspec_v2(
	benchmark: BenchmarkFixture,
	cpython_files: set[str],
	cpython_gi_lines_all: list[str],
):
	spec = PathSpec.from_lines(
		lines=cpython_gi_lines_all,
		pattern_factory='gitwildmatch',
		backend='simple',
	)
	benchmark(run_match, spec, cpython_files)


def run_match(spec: GitIgnoreSpec, files: set[str]):
	for _ in spec.match_files(files):
		pass