Skip to content

Commit b196174

Browse files
author
Ross Bayer
committed
[Python: black] Reformatted the benchmark Python sources using utils/python_format.py.
1 parent d4eaf90 commit b196174

16 files changed

+2277
-1585
lines changed

benchmark/scripts/Benchmark_DTrace.in

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,61 +19,56 @@ import sys
1919

2020
DRIVER_LIBRARY_PATH = "@PATH_TO_DRIVER_LIBRARY@"
2121
sys.path.append(DRIVER_LIBRARY_PATH)
22-
DTRACE_PATH = os.path.join(DRIVER_LIBRARY_PATH, 'swift_stats.d')
22+
DTRACE_PATH = os.path.join(DRIVER_LIBRARY_PATH, "swift_stats.d")
2323

2424
import perf_test_driver # noqa (E402 module level import not at top of file)
2525

2626
# Regexes for the XFAIL_LIST. Matches against '([Onone|O|Osize],TestName)'
27-
XFAIL_LIST = [
28-
]
27+
XFAIL_LIST = []
2928

3029

3130
class DTraceResult(perf_test_driver.Result):
32-
3331
def __init__(self, name, status, output, csv_output):
34-
perf_test_driver.Result.__init__(
35-
self, name, status, output, XFAIL_LIST)
32+
perf_test_driver.Result.__init__(self, name, status, output, XFAIL_LIST)
3633
self.csv_output = csv_output
3734

3835
def is_failure(self):
3936
return not bool(self.status)
4037

4138
@classmethod
4239
def data_headers(cls):
43-
return [
44-
'Name', 'Result', 'Total RR Opts', 'Total RR Opts/Iter']
40+
return ["Name", "Result", "Total RR Opts", "Total RR Opts/Iter"]
4541

4642
@classmethod
4743
def data_format(cls, max_test_len):
4844
non_name_headers = DTraceResult.data_headers()[1:]
49-
fmt = ('{:<%d}' % (max_test_len + 5)) + \
50-
''.join(['{:<%d}' % (len(h) + 2) for h in non_name_headers])
45+
fmt = ("{:<%d}" % (max_test_len + 5)) + "".join(
46+
["{:<%d}" % (len(h) + 2) for h in non_name_headers]
47+
)
5148
return fmt
5249

5350
@classmethod
5451
def print_data_header(cls, max_test_len, csv_output):
5552
headers = cls.data_headers()
5653
if csv_output:
57-
print(','.join(headers))
54+
print(",".join(headers))
5855
return
5956
print(cls.data_format(max_test_len).format(*headers))
6057

6158
def print_data(self, max_test_len):
6259
result = [self.get_name(), self.get_result()] + map(str, self.output)
6360
if self.csv_output:
64-
print(','.join(result))
61+
print(",".join(result))
6562
return
6663

6764
print(DTraceResult.data_format(max_test_len).format(*result))
6865

6966

7067
class DTraceBenchmarkDriver(perf_test_driver.BenchmarkDriver):
71-
7268
def __init__(self, binary, xfail_list, csv_output):
7369
perf_test_driver.BenchmarkDriver.__init__(
74-
self, binary, xfail_list,
75-
enable_parallel=True,
76-
opt_levels=['O'])
70+
self, binary, xfail_list, enable_parallel=True, opt_levels=["O"]
71+
)
7772
self.csv_output = csv_output
7873

7974
def print_data_header(self, max_test_len):
@@ -83,23 +78,37 @@ class DTraceBenchmarkDriver(perf_test_driver.BenchmarkDriver):
8378
return {}
8479

8580
def process_input(self, data):
86-
test_name = '({}_{})'.format(data['opt'], data['test_name'])
81+
test_name = "({}_{})".format(data["opt"], data["test_name"])
8782
print("Running {}...".format(test_name))
8883
sys.stdout.flush()
8984

9085
def get_results_with_iters(iters):
9186
e = os.environ
92-
e['SWIFT_DETERMINISTIC_HASHING'] = '1'
93-
p = subprocess.Popen([
94-
'sudo', 'dtrace', '-s', DTRACE_PATH,
95-
'-c', '%s %s %s %s' % (data['path'], data['test_name'],
96-
'--num-iters=%d' % iters,
97-
'--num-samples=2')
98-
], stdout=subprocess.PIPE, stderr=open('/dev/null', 'w'), env=e)
87+
e["SWIFT_DETERMINISTIC_HASHING"] = "1"
88+
p = subprocess.Popen(
89+
[
90+
"sudo",
91+
"dtrace",
92+
"-s",
93+
DTRACE_PATH,
94+
"-c",
95+
"%s %s %s %s"
96+
% (
97+
data["path"],
98+
data["test_name"],
99+
"--num-iters=%d" % iters,
100+
"--num-samples=2",
101+
),
102+
],
103+
stdout=subprocess.PIPE,
104+
stderr=open("/dev/null", "w"),
105+
env=e,
106+
)
99107
results = [x for x in p.communicate()[0].split("\n") if len(x) > 0]
100108
return [
101-
x.split(',')[1] for x in
102-
results[results.index('DTRACE RESULTS') + 1:]]
109+
x.split(",")[1] for x in results[results.index("DTRACE RESULTS") + 1 :]
110+
]
111+
103112
iter_2_results = get_results_with_iters(2)
104113
iter_3_results = get_results_with_iters(3)
105114
iter_5_results = get_results_with_iters(5)
@@ -136,16 +145,18 @@ SWIFT_BIN_DIR = os.path.dirname(os.path.abspath(__file__))
136145
def parse_args():
137146
parser = argparse.ArgumentParser()
138147
parser.add_argument(
139-
'-filter',
148+
"-filter",
140149
type=str,
141150
default=None,
142-
help='Filter out any test that does not match the given regex')
151+
help="Filter out any test that does not match the given regex",
152+
)
143153
parser.add_argument(
144-
'--emit-csv',
154+
"--emit-csv",
145155
default=False,
146-
action='store_true',
156+
action="store_true",
147157
help="Emit csv output",
148-
dest='csv_output')
158+
dest="csv_output",
159+
)
149160
return parser.parse_args()
150161

151162

0 commit comments

Comments
 (0)