27
27
28
28
# Common ASV arguments for all run_types except `custom`.
29
29
ASV_HARNESS = (
30
- "run {posargs} --attribute rounds=4 --interleave-rounds --strict "
30
+ "{command} {posargs} --attribute rounds=4 --interleave-rounds --strict "
31
31
"--show-stderr"
32
32
)
33
33
@@ -127,37 +127,6 @@ def _setup_common() -> None:
127
127
echo ("Setup complete." )
128
128
129
129
130
- def _asv_compare (* commits : str , overnight_mode : bool = False ) -> None :
131
- """Run through a list of commits comparing each one to the next."""
132
- commits = [commit [:8 ] for commit in commits ]
133
- shifts_dir = BENCHMARKS_DIR / ".asv" / "performance-shifts"
134
- for i in range (len (commits ) - 1 ):
135
- before = commits [i ]
136
- after = commits [i + 1 ]
137
- asv_command = (
138
- f"compare { before } { after } --factor={ COMPARE_FACTOR } --split"
139
- )
140
- _subprocess_run_asv (asv_command .split (" " ))
141
-
142
- if overnight_mode :
143
- # Record performance shifts.
144
- # Run the command again but limited to only showing performance
145
- # shifts.
146
- shifts = _subprocess_run_asv (
147
- [* asv_command .split (" " ), "--only-changed" ],
148
- capture_output = True ,
149
- text = True ,
150
- ).stdout
151
- if shifts :
152
- # Write the shifts report to a file.
153
- # Dir is used by .github/workflows/benchmarks.yml,
154
- # but not cached - intended to be discarded after run.
155
- shifts_dir .mkdir (exist_ok = True , parents = True )
156
- shifts_path = (shifts_dir / after ).with_suffix (".txt" )
157
- with shifts_path .open ("w" ) as shifts_file :
158
- shifts_file .write (shifts )
159
-
160
-
161
130
class _SubParserGenerator (ABC ):
162
131
"""Convenience for holding all the necessary argparse info in 1 place."""
163
132
@@ -225,7 +194,7 @@ def func(args: argparse.Namespace) -> None:
225
194
_setup_common ()
226
195
227
196
commit_range = f"{ args .first_commit } ^^.."
228
- asv_command = ASV_HARNESS .format (posargs = commit_range )
197
+ asv_command = ASV_HARNESS .format (command = "run" , posargs = commit_range )
229
198
_subprocess_run_asv ([* asv_command .split (" " ), * args .asv_args ])
230
199
231
200
# git rev-list --first-parent is the command ASV uses.
@@ -234,6 +203,35 @@ def func(args: argparse.Namespace) -> None:
234
203
git_command .split (" " ), capture_output = True , text = True
235
204
).stdout
236
205
commit_list = commit_string .rstrip ().split ("\n " )
206
+
207
+ # Run through the list of commits comparing each one to the next.
208
+ commits = [commit [:8 ] for commit in commit_list ]
209
+ shifts_dir = BENCHMARKS_DIR / ".asv" / "performance-shifts"
210
+ for i in range (len (commits ) - 1 ):
211
+ before = commits [i ]
212
+ after = commits [i + 1 ]
213
+ asv_command = (
214
+ f"compare { before } { after } --factor={ COMPARE_FACTOR } --split"
215
+ )
216
+ _subprocess_run_asv (asv_command .split (" " ))
217
+
218
+ # Record performance shifts.
219
+ # Run the command again but limited to only showing performance
220
+ # shifts.
221
+ shifts = _subprocess_run_asv (
222
+ [* asv_command .split (" " ), "--only-changed" ],
223
+ capture_output = True ,
224
+ text = True ,
225
+ ).stdout
226
+ if shifts :
227
+ # Write the shifts report to a file.
228
+ # Dir is used by .github/workflows/benchmarks.yml,
229
+ # but not cached - intended to be discarded after run.
230
+ shifts_dir .mkdir (exist_ok = True , parents = True )
231
+ shifts_path = (shifts_dir / after ).with_suffix (".txt" )
232
+ with shifts_path .open ("w" ) as shifts_file :
233
+ shifts_file .write (shifts )
234
+
237
235
_asv_compare (* reversed (commit_list ), overnight_mode = True )
238
236
239
237
@@ -269,14 +267,13 @@ def func(args: argparse.Namespace) -> None:
269
267
git_command .split (" " ), capture_output = True , text = True
270
268
).stdout [:8 ]
271
269
272
- with NamedTemporaryFile ("w" ) as hashfile :
273
- hashfile .writelines ([merge_base , "\n " , "HEAD" ])
274
- hashfile .flush ()
275
- commit_range = f"HASHFILE:{ hashfile .name } "
276
- asv_command = ASV_HARNESS .format (posargs = commit_range )
277
- _subprocess_run_asv ([* asv_command .split (" " ), * args .asv_args ])
278
-
279
- _asv_compare (merge_base , "HEAD" )
270
+ asv_command = (
271
+ ASV_HARNESS .format (
272
+ command = "continuous" , posargs = f"HEAD { merge_base } "
273
+ )
274
+ + f" --factor={ COMPARE_FACTOR } "
275
+ )
276
+ _subprocess_run_asv ([* asv_command .split (" " ), * args .asv_args ])
280
277
281
278
282
279
class _CSPerf (_SubParserGenerator , ABC ):
@@ -324,7 +321,8 @@ def csperf(
324
321
commit_range = "upstream/main^!"
325
322
326
323
asv_command = (
327
- ASV_HARNESS .format (posargs = commit_range ) + f" --bench={ run_type } "
324
+ ASV_HARNESS .format (command = "run" , posargs = commit_range )
325
+ + f" --bench={ run_type } "
328
326
)
329
327
# C/SPerf benchmarks are much bigger than the CI ones:
330
328
# Don't fail the whole run if memory blows on 1 benchmark.
0 commit comments