forked from spcl/npbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_framework.py
56 lines (52 loc) · 2.05 KB
/
run_framework.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import argparse
import os
import pathlib
from multiprocessing import Process
from npbench.infrastructure import (Benchmark, generate_framework, LineCount,
Test, utilities as util)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-f",
"--framework",
type=str,
nargs="?",
default="numpy")
parser.add_argument("-p",
"--preset",
choices=['S', 'M', 'L', 'paper'],
nargs="?",
default='S')
parser.add_argument("-m", "--mode", type=str, nargs="?", default="main")
parser.add_argument("-v",
"--validate",
type=util.str2bool,
nargs="?",
default=True)
parser.add_argument("-r", "--repeat", type=int, nargs="?", default=10)
parser.add_argument("-t",
"--timeout",
type=float,
nargs="?",
default=200.0)
args = vars(parser.parse_args())
def run_benchmark(benchname, fname, preset, validate, repeat, timeout):
frmwrk = generate_framework(fname)
numpy = generate_framework("numpy")
bench = Benchmark(benchname)
lcount = LineCount(bench, frmwrk, numpy)
lcount.count()
test = Test(bench, frmwrk, numpy)
test.run(preset, validate, repeat, timeout)
parent_folder = pathlib.Path(__file__).parent.absolute()
bench_dir = parent_folder.joinpath("bench_info")
pathlist = pathlib.Path(bench_dir).rglob('*.json')
benchnames = [os.path.basename(path)[:-5] for path in pathlist]
benchnames.sort()
for benchname in benchnames:
p = Process(
target=run_benchmark,
args=(benchname, args["framework"], args["preset"],
args["validate"], args["repeat"], args["timeout"])
)
p.start()
p.join()