Skip to content

Commit 2607662

Browse files
committed
add -p/--paths option for harness: set the system path to search for extra modules needed by the benchmark
fix -p
1 parent 339300f commit 2607662

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

graalpython/benchmarks/src/harness.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ def _call_attr(self, attr_name, *args):
132132
return attr(*args)
133133

134134
def run(self):
135-
print(_HRULE)
136135
if self._run_once:
137136
print("### %s, exactly one iteration (no warmup curves)" % (self.bench_module.__name__))
138137
else:
@@ -163,16 +162,19 @@ def run(self):
163162
else:
164163
print("### iteration=%s, name=%s, duration=%s" % (iteration, self.bench_module.__name__, duration))
165164

166-
print("teardown ... ")
165+
print(_HRULE)
166+
print("### teardown ... ")
167167
self._call_attr(ATTR_TEARDOWN)
168-
print("benchmark complete")
168+
print("### benchmark complete")
169+
print(_HRULE)
169170

170171

171-
def run_benchmark(prog, args):
172+
def run_benchmark(args):
172173
warmup = 0
173174
iterations = 1
174175
bench_file = None
175176
bench_args = []
177+
paths = []
176178

177179
i = 0
178180
while i < len(args):
@@ -182,19 +184,36 @@ def run_benchmark(prog, args):
182184
iterations = _as_int(args[i])
183185
elif arg.startswith("--iterations"):
184186
iterations = _as_int(arg.split("=")[1])
187+
185188
elif arg == '-w':
186189
i += 1
187190
warmup = _as_int(args[i])
188191
elif arg.startswith("--warmup"):
189192
warmup = _as_int(arg.split("=")[1])
193+
194+
elif arg == '-p':
195+
i += 1
196+
paths = args[i].split(",")
197+
elif arg.startswith("--path"):
198+
paths = arg.split("=")[1].split(",")
199+
190200
elif bench_file is None:
191201
bench_file = arg
192202
else:
193203
bench_args.append(arg)
194204
i += 1
195205

206+
# set the paths if specified
207+
print(_HRULE)
208+
if paths:
209+
for pth in paths:
210+
print("### adding module path: %s" % pth)
211+
sys.path.append(pth)
212+
else:
213+
print("### no extra module search paths specified")
214+
196215
BenchRunner(bench_file, bench_args=bench_args, iterations=iterations, warmup=warmup).run()
197216

198217

199218
if __name__ == '__main__':
200-
run_benchmark(sys.argv[0], sys.argv[1:])
219+
run_benchmark(sys.argv[1:])

0 commit comments

Comments
 (0)