-
Notifications
You must be signed in to change notification settings - Fork 4
/
benchmark
executable file
·28 lines (23 loc) · 1023 Bytes
/
benchmark
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
#!/usr/bin/env python
#
# Run and visualize a benchmark test.
import argparse
import subprocess
import cProfile
from benchmarks import benchmarks
def main(benchmark, study, engine, dtype_backend):
class_name, method_name = benchmark.split('.')
test = getattr(benchmarks, class_name)
m = test(study, engine=engine, dtype_backend=dtype_backend)
m.setup()
sub_test = getattr(m, method_name)
cProfile.runctx('sub_test()', globals(), locals(), filename='.profile')
subprocess.Popen(['snakeviz', '.profile'])
if __name__ == '__main__':
parser = argparse.ArgumentParser('Run and visualize a benchmark test.')
parser.add_argument('--study', '-s', default='Morton2013')
parser.add_argument('--engine', '-e', default='python')
parser.add_argument('--dtype-backend', '-d', default='numpy_nullable')
parser.add_argument('benchmark', help="benchmark to run (classname.methodname)")
args = parser.parse_args()
main(args.benchmark, args.study, args.engine, args.dtype_backend)