-
Notifications
You must be signed in to change notification settings - Fork 2
/
bencher.py
executable file
·64 lines (51 loc) · 1.93 KB
/
bencher.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
#!/usr/bin/env python
from __future__ import with_statement
import os
import time
import subprocess
from datetime import datetime as dt
from datetime import timedelta
from socket import gethostname
HOST = gethostname()
def run(command):
proc = subprocess.Popen(command,
shell=True,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE)
return "\n".join(proc.communicate())
def write_log(fname, data, number):
if not os.path.isdir("logs"):
os.mkdir("logs")
path = "logs/%s-%s.log" % (HOST, fname)
with open(path, 'a') as f:
f.write("\n\nRun: %s\nDate: %s\n\n" % (number, dt.now()))
f.write(data)
os.system("git add %s" % path)
if __name__ == "__main__":
test_dir = './django/tests'
python_path = "export PYTHONPATH=django:."
d_cmd_template = "%s && time %s/runtests.py --settings=" % (python_path,
test_dir)
d_cmd = lambda setting: "%s%s" % (d_cmd_template, setting)
usr = "testuser"
pwd = "n0ns3curepWd"
tests = "time ./run-all-tests --silent " + \
"--server=Pg --user=%s --password=%s" % (usr, pwd)
p_cmd = "cd mysql-5.1.34/sql-bench && %s" % tests
u_cmd = "cd unixbench-5.1.2 && time ./Run"
start = dt.now()
for i in range(1, 10000):
print "Running %s" % i
write_log('django_sqlite3_test', run(d_cmd("sqlite3conf")), i)
time.sleep(60*5)
write_log('django_pgsql_test', run(d_cmd("pgsqlconf")), i)
time.sleep(60*5)
write_log('pgsql_mysql_benchmark', run(p_cmd), i)
time.sleep(60*5)
write_log('unix_benchmark', run(u_cmd), i)
os.system('git pull')
os.system('git commit -m "Logging run %s (%s)"' % (i, HOST))
os.system('git push')
while dt.now() - start < timedelta(hours=3):
time.sleep(10)
start = dt.now()