-
Notifications
You must be signed in to change notification settings - Fork 2
/
suite.py
129 lines (100 loc) · 3.24 KB
/
suite.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from datetime import datetime
import logging
import os, sys
import glob
import subprocess
from vbench.api import collect_benchmarks
from benchmarks.utils import cd
BASEDIR = os.path.dirname(os.path.realpath(__file__))
log = logging.getLogger('vb')
log.setLevel(logging.INFO)
with cd(os.path.join(BASEDIR, 'benchmarks')):
filenames = glob.glob("vb*.py")
names = [filename[:-3] for filename in filenames]
print(names)
benchmarks = collect_benchmarks(names)
log.info("Initializing settings")
REPO_PATH = os.path.join(BASEDIR, 'dit')
REPO_URL = 'git://github.com/dit/dit.git'
REPO_BROWSE = 'https://github.com/dit/dit'
DB_PATH = os.path.join(BASEDIR, 'db/benchmarks.db')
TMP_DIR = os.path.join(BASEDIR, 'tmp')
# Assure corresponding directories existence
for s in (REPO_PATH, os.path.dirname(DB_PATH), TMP_DIR):
if not os.path.exists(s):
os.makedirs(s)
BRANCHES = ['master']
PREPARE = """
git clean -dfx
"""
BUILD = """
python setup.py build_ext --inplace
"""
START_DATE = datetime(2014, 9, 1)
RST_BASE = 'source'
dependencies = []
DESCRIPTION = """
These historical benchmark graphs were produced with `vbench
<http://github.com/pydata/vbench>`__ (ATM with yet to be integrated
upstream changes in https://github.com/pydata/vbench/pull/33).
"""
HARDWARE = """
Results were collected on the following machine:
- {uname}
- CPU: {cpu}
- Memory: {mem}
- {dist}
- Python {python}
``lscpu`` output::
{lscpu}
"""
try:
subs = {}
p = subprocess.Popen(['uname', '-srmpio'], stdout=subprocess.PIPE)
out, err = p.communicate()
subs['uname'] = out.strip()
p = subprocess.Popen('cat /proc/cpuinfo | grep --color=no "model name"',
shell=True, stdout=subprocess.PIPE)
out, err = p.communicate()
out = out.split('\n')[0]
out = out.split(':')[1].strip()
subs['cpu'] = out
p = subprocess.Popen('cat /proc/meminfo | grep --color=no MemTotal',
shell=True, stdout=subprocess.PIPE)
out, err = p.communicate()
out = out.split('\n')[0]
out = out.split(':')[1].strip()
subs['mem'] = out
try:
p = subprocess.Popen('cat /etc/lsb-release',
shell=True, stdout=subprocess.PIPE)
out, err = p.communicate()
# Grab last line
out = out.strip().split('\n')[-1]
# Take away quotes in content after equals sign.
out = out.split('=')[1][1:-1]
subs['dist'] = out
except:
subs['dist'] = ''
subs['python'] = "{}.{}.{}".format(*sys.version_info[:3])
p = subprocess.Popen('lscpu', shell=True, stdout=subprocess.PIPE)
out, err = p.communicate()
subs['lscpu'] = ' '+ '\n '.join(out.split('\n'))
except:
pass
else:
if subs:
HARDWARE = HARDWARE.format(**subs)
DESCRIPTION += HARDWARE
filename = os.path.join(BASEDIR, 'db', 'hardware.txt')
if os.path.isfile(filename):
with open(filename) as f:
data = f.read()
if data != HARDWARE:
msg = 'Database exists and was created using different hardware.'
print(msg)
print("\nEXISTING:\n{0}".format(data))
print("\nCURRENT:\n{0}".format(HARDWARE))
else:
with open(filename, 'w') as f:
f.write(HARDWARE)