-
Notifications
You must be signed in to change notification settings - Fork 8
/
bench_over_time.py
87 lines (75 loc) · 2.49 KB
/
bench_over_time.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import subprocess as sp
# import tinydb
import os
import shutil
absdir = os.path.dirname(os.path.realpath(__file__))
CONDA_PREFIX = None
XTENSOR_VERSION = [0, 0, 0]
def call(arguments):
print(arguments)
os.system(" ".join(arguments))
def parse_version():
global XTENSOR_VERSION
os.chdir(absdir + '/checkouts/xtensor')
with open(absdir + '/checkouts/xtensor/include/xtensor/xtensor_config.hpp') as f:
for line in f.readlines():
if line.startswith("#define XTENSOR_VERSION_MAJOR"):
XTENSOR_VERSION[0] = int(line.split()[-1])
if line.startswith("#define XTENSOR_VERSION_MINOR"):
XTENSOR_VERSION[1] = int(line.split()[-1])
if line.startswith("#define XTENSOR_VERSION_PATCH"):
XTENSOR_VERSION[2] = int(line.split()[-1])
print(f"Testing against: {XTENSOR_VERSION}")
def init():
global CONDA_PREFIX
try:
call(['conda', 'env', 'create'])
except:
pass
try:
shutil.rmtree(absdir + '/stats')
except:
pass
call(['source', 'activate', 'xtensor-benchmark'])
CONDA_PREFIX = os.environ['CONDA_PREFIX']
print(f"CONDA PREFIX SET TO: {CONDA_PREFIX}")
def install_xtensor_version(version):
try:
os.mkdir(absdir + '/checkouts')
call(['git', 'clone', 'https://github.com/xtensor-stack/xtensor'])
except:
os.chdir(absdir + '/checkouts/xtensor')
call(['git', 'checkout', 'master'])
call(['git', 'pull'])
call(['git', 'checkout', version])
parse_version()
version_string = ".".join([str(el) for el in XTENSOR_VERSION])
call(['conda', 'install', f'xtensor=={version_string}', '-c conda-forge', '-y'])
try:
os.mkdir(absdir + '/checkouts/xtensor/build')
except:
pass
os.chdir(absdir + '/checkouts/xtensor/build')
call(['cmake', '..', '-DCMAKE_INSTALL_LIBDIR=lib', f'-DCMAKE_INSTALL_PREFIX={CONDA_PREFIX}'])
call(['make', 'install'])
def build_and_bench(version):
try:
os.mkdir(absdir + '/build')
except:
pass
os.chdir(absdir + '/build')
try:
os.mkdir(absdir + '/stats')
except:
pass
call(['cmake', '..', '-DBENCHMARK_EIGEN=ON'])
call(['make', 'xpowerbench'])
os.rename(absdir + '/build/bench.csv', absdir + f'/stats/{version}.csv')
def run():
init()
versions = ['master', '0.15.4', '0.14.0']
for v in versions:
install_xtensor_version(v)
build_and_bench(v)
if __name__ == '__main__':
run()