Commit 9d7cdd44 authored by Mikaël Salson's avatar Mikaël Salson

tools/benchmark-releases.py: Do not time everything

We cannot use time on some commands such as the ones with cd
parent d8f440dd
...@@ -79,15 +79,16 @@ parser.add_argument('-b', '--benchmark', action='store_true', help='benchmark in ...@@ -79,15 +79,16 @@ parser.add_argument('-b', '--benchmark', action='store_true', help='benchmark in
parser.add_argument('-r', '--retries', type=int, default=1, help='Number of times each benchmark is launched') parser.add_argument('-r', '--retries', type=int, default=1, help='Number of times each benchmark is launched')
def go(cmd, log=None): def go(cmd, log=None, time=False):
if log: if log:
flog = open(log, 'a') flog = open(log, 'a')
flog.write('\n\n%s\n' % cmd) flog.write('\n\n%s\n' % cmd)
else: else:
flog = sys.stdout flog = sys.stdout
print(cmd, end=' ') print(cmd, end=' ')
time_file = NamedTemporaryFile(mode='w+', delete=False) if time:
cmd = "/usr/bin/time -o {} -f '%U\t%S\t%M' {}".format(time_file.name, cmd) time_file = NamedTemporaryFile(mode='w+', delete=False)
cmd = "/usr/bin/time -o {} -f '%U\t%S\t%M' {}".format(time_file.name, cmd)
returncode = subprocess.call(cmd, shell=True, stderr=subprocess.STDOUT, stdout=flog) returncode = subprocess.call(cmd, shell=True, stderr=subprocess.STDOUT, stdout=flog)
if log: if log:
flog.close() flog.close()
...@@ -95,6 +96,8 @@ def go(cmd, log=None): ...@@ -95,6 +96,8 @@ def go(cmd, log=None):
if returncode: if returncode:
print('FAILED', end=' ') print('FAILED', end=' ')
raise subprocess.CalledProcessError(returncode, cmd) raise subprocess.CalledProcessError(returncode, cmd)
elif not time:
return
else: else:
(utime, stime, mem) = [ float(i) for i in time_file.read().split() ] (utime, stime, mem) = [ float(i) for i in time_file.read().split() ]
...@@ -174,7 +177,7 @@ def run_all(tag, args, retries): ...@@ -174,7 +177,7 @@ def run_all(tag, args, retries):
try: try:
benchs = [] benchs = []
for i in range(retries) : for i in range(retries) :
benchs.append(go(cmd, log)) benchs.append(go(cmd, log, True))
time = min([b[0] for b in benchs]) time = min([b[0] for b in benchs])
mem = min([b[1] for b in benchs]) mem = min([b[1] for b in benchs])
stats[tag,release] = (time, mem) stats[tag,release] = (time, mem)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment