Skip to content

Commit 4bbd45e

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 93526c2 commit 4bbd45e

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

misc/perf_compare.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def run_benchmark(
9999

100100
def main() -> None:
101101
whole_program_time_0 = time.time()
102-
parser = argparse.ArgumentParser(epilog="Remember: you usually want the first argument to this command to be 'master'.")
102+
parser = argparse.ArgumentParser(
103+
epilog="Remember: you usually want the first argument to this command to be 'master'."
104+
)
103105
parser.add_argument(
104106
"--incremental",
105107
default=False,
@@ -131,8 +133,8 @@ def main() -> None:
131133
metavar="FOREIGN_REPOSITORY",
132134
default=None,
133135
type=str,
134-
help="measure time to type check the project at FOREIGN_REPOSITORY instead of mypy self-check; " +
135-
"provided value must be the URL or path of a git repo",
136+
help="measure time to type check the project at FOREIGN_REPOSITORY instead of mypy self-check; "
137+
+ "provided value must be the URL or path of a git repo",
136138
)
137139
parser.add_argument(
138140
"-c",
@@ -192,7 +194,13 @@ def main() -> None:
192194
items = list(enumerate(commits))
193195
random.shuffle(items)
194196
for i, commit in items:
195-
tt = run_benchmark(target_dirs[i], check_dir, incremental=incremental, code=code, foreign=bool(foreign_repo))
197+
tt = run_benchmark(
198+
target_dirs[i],
199+
check_dir,
200+
incremental=incremental,
201+
code=code,
202+
foreign=bool(foreign_repo),
203+
)
196204
# Don't record the first warm-up run
197205
if n > 0:
198206
print(f"{commit}: t={tt:.3f}s")
@@ -203,7 +211,7 @@ def main() -> None:
203211
first = -1.0
204212
for commit in commits:
205213
tt = statistics.mean(results[commit])
206-
#pstdev (instead of stdev) is used here primarily to accommodate the case where num_runs=1
214+
# pstdev (instead of stdev) is used here primarily to accommodate the case where num_runs=1
207215
s = statistics.pstdev(results[commit]) if len(results[commit]) > 1 else 0
208216
if first < 0:
209217
delta = "0.0%"
@@ -213,11 +221,16 @@ def main() -> None:
213221
delta = f"{d:+.1%}"
214222
print(f"{commit:<25} {tt:.3f}s ({delta}) | stdev {s:.3f}s ")
215223

216-
t = int( time.time() - whole_program_time_0 )
224+
t = int(time.time() - whole_program_time_0)
217225
total_time_taken_formatted = ", ".join(
218-
f"{v} {n if v==1 else n+'s'}" for v, n in ((t//3600, "hour"), (t//60%60, "minute"), (t%60, "second")) if v
226+
f"{v} {n if v==1 else n+'s'}"
227+
for v, n in ((t // 3600, "hour"), (t // 60 % 60, "minute"), (t % 60, "second"))
228+
if v
229+
)
230+
print(
231+
"Total time taken by the whole benchmarking program (including any setup):",
232+
total_time_taken_formatted,
219233
)
220-
print("Total time taken by the whole benchmarking program (including any setup):", total_time_taken_formatted)
221234

222235
shutil.rmtree(check_dir)
223236
for target_dir in target_dirs:

0 commit comments

Comments
 (0)