Browse Source

Avoid depending on 'time' command in time_multi.py

pull/2106/head
Sami Vaarala 6 years ago
parent
commit
514b6e1b86
  1. 10
      util/time_multi.py

10
util/time_multi.py

@ -58,11 +58,7 @@ def main():
for i in xrange(opts.count): for i in xrange(opts.count):
time.sleep(opts.sleep) time.sleep(opts.sleep)
cmd = [ cmd = []
'time',
'-f', '%U',
'--quiet'
]
cmd = cmd + args cmd = cmd + args
#print(repr(cmd)) #print(repr(cmd))
@ -74,6 +70,7 @@ def main():
killed = False killed = False
retval = -1 retval = -1
time_start = time.time()
try: try:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
@ -87,6 +84,7 @@ def main():
os.kill(p.pid, signal.SIGKILL) os.kill(p.pid, signal.SIGKILL)
retval = p.wait() retval = p.wait()
time.sleep(opts.kill_wait) time.sleep(opts.kill_wait)
time_end = time.time()
run = { run = {
'cmd': cmd, 'cmd': cmd,
@ -114,7 +112,7 @@ def main():
doc['failed'] = True doc['failed'] = True
break break
time_this = float(stderr) time_this = time_end - time_start
#print(i, time_this) #print(i, time_this)
if time_min is None: if time_min is None:

Loading…
Cancel
Save