Skip to content

Commit 30e1a71

Browse files
committed
whitespace
1 parent 79fab52 commit 30e1a71

File tree

2 files changed

+47
-24
lines changed

2 files changed

+47
-24
lines changed

benchmark/plot_benchmarks.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
from matplotlib import pyplot as plt, lines
88
import shelve
9-
import json
10-
import subprocess as subp
11-
import sys
129
from collections import defaultdict
1310
from run_benchmarks import get_commits, run
1411
import numpy as np
@@ -19,6 +16,7 @@
1916

2017
commits, comments = get_commits()
2118

19+
2220
def get_benchmarks(results):
2321
benchmarks = defaultdict(lambda: [])
2422
for hash in commits:
@@ -30,6 +28,7 @@ def get_benchmarks(results):
3028
benchmarks[name].append((commits.index(hash), time))
3129
return benchmarks
3230

31+
3332
with shelve.open("benchmark_results") as results:
3433
benchmarks = get_benchmarks(results)
3534

@@ -38,37 +37,44 @@ def get_benchmarks(results):
3837

3938
plt.sca(ax[0])
4039
for name, xy in benchmarks.items():
41-
if "uniform" in name: continue
40+
if "uniform" in name:
41+
continue
4242
if "_1d" in name:
4343
x, y = np.transpose(xy)
4444
plt.plot(x, y, ".-", label=name)
4545
plt.legend(fontsize="xx-small")
4646

4747
plt.sca(ax[1])
4848
for name, xy in benchmarks.items():
49-
if "uniform" in name: continue
49+
if "uniform" in name:
50+
continue
5051
if "_2d" in name:
5152
x, y = np.transpose(xy)
5253
plt.plot(x, y, ".-", label=name)
5354
plt.legend(fontsize="xx-small")
5455

5556
plt.sca(ax[2])
5657
for name, xy in benchmarks.items():
57-
if "uniform" in name: continue
58+
if "uniform" in name:
59+
continue
5860
if "_3d" in name:
5961
x, y = np.transpose(xy)
6062
plt.plot(x, y, ".-", label=name)
6163
plt.legend(fontsize="xx-small")
6264

6365
plt.sca(ax[3])
6466
for name, xy in benchmarks.items():
65-
if "uniform" in name: continue
67+
if "uniform" in name:
68+
continue
6669
if "_6d" in name:
6770
x, y = np.transpose(xy)
6871
plt.plot(x, y, ".-", label=name)
6972
plt.legend(fontsize="xx-small")
7073

71-
plt.figtext(0.01, 0.5, "time per loop / ns [smaller is better]", rotation=90, va="center")
74+
plt.figtext(
75+
0.01, 0.5, "time per loop / ns [smaller is better]", rotation=90, va="center"
76+
)
77+
7278

7379
def format_coord(x, y):
7480
global current_index
@@ -77,14 +83,18 @@ def format_coord(x, y):
7783
comment = comments[hash]
7884
return f"{hash} {comment}"
7985

86+
8087
for axi in ax.flatten():
8188
axi.format_coord = format_coord
8289

90+
8391
def on_key_press(event):
8492
global thread
85-
if thread and thread.is_alive(): return
93+
if thread and thread.is_alive():
94+
return
8695

87-
if event.key != "u": return
96+
if event.key != "u":
97+
return
8898

8999
hash = commits[current_index]
90100

@@ -107,6 +117,7 @@ def worker(fig, ax, hash):
107117
thread = threading.Thread(target=worker, args=(fig, ax, hash))
108118
thread.start()
109119

110-
fig.canvas.mpl_connect('key_press_event', on_key_press)
120+
121+
fig.canvas.mpl_connect("key_press_event", on_key_press)
111122

112123
plt.show()

benchmark/run_benchmarks.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"""
2727
import subprocess as subp
2828
import tempfile
29-
import os
3029
import shelve
3130
import json
3231
import argparse
@@ -35,12 +34,14 @@
3534
def get_commits():
3635
commits = []
3736
comments = {}
38-
for line in subp.check_output(("git", "log", "--oneline")).decode("ascii").split("\n"):
37+
for line in (
38+
subp.check_output(("git", "log", "--oneline")).decode("ascii").split("\n")
39+
):
3940
if line:
4041
ispace = line.index(" ")
4142
hash = line[:ispace]
4243
commits.append(hash)
43-
comments[hash] = line[ispace+1:]
44+
comments[hash] = line[ispace + 1 :]
4445
commits = commits[::-1]
4546
return commits, comments
4647

@@ -72,7 +73,9 @@ def run(results, comments, hash, update):
7273
print(out.read().decode("utf-8") + "\n")
7374
return
7475
print(hash, "run")
75-
s = subp.check_output(("./histogram_filling", "--benchmark_format=json", "--benchmark_filter=normal"))
76+
s = subp.check_output(
77+
("./histogram_filling", "--benchmark_format=json", "--benchmark_filter=normal")
78+
)
7679
d = json.loads(s)
7780
if update and hash in results and results[hash] is not None:
7881
d2 = results[hash]
@@ -86,14 +89,22 @@ def run(results, comments, hash, update):
8689
def main():
8790
commits, comments = get_commits()
8891

89-
parser = argparse.ArgumentParser(description=__doc__,
90-
formatter_class=argparse.RawDescriptionHelpFormatter)
91-
parser.add_argument("first", type=str, default="begin",
92-
help="first commit in range, special value `begin` is allowed")
93-
parser.add_argument("last", type=str, default="end",
94-
help="last commit in range, special value `end` is allowed")
95-
parser.add_argument("-f", action="store_true",
96-
help="override previous results")
92+
parser = argparse.ArgumentParser(
93+
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
94+
)
95+
parser.add_argument(
96+
"first",
97+
type=str,
98+
default="begin",
99+
help="first commit in range, special value `begin` is allowed",
100+
)
101+
parser.add_argument(
102+
"last",
103+
type=str,
104+
default="end",
105+
help="last commit in range, special value `end` is allowed",
106+
)
107+
parser.add_argument("-f", action="store_true", help="override previous results")
97108

98109
args = parser.parse_args()
99110

@@ -106,11 +117,12 @@ def main():
106117
a = commits.index(args.first)
107118
b = commits.index(args.last)
108119
if args.f:
109-
for hash in commits[a:b+1]:
120+
for hash in commits[a : b + 1]:
110121
del results[hash]
111122
run(results, comments, args.first, False)
112123
run(results, comments, args.last, False)
113124
recursion(results, commits, comments, a, b)
114125

126+
115127
if __name__ == "__main__":
116128
main()

0 commit comments

Comments
 (0)