From 28cedf169580f0b9847f2330a00dec9dd6041ab5 Mon Sep 17 00:00:00 2001 From: KiYugadgeter Date: Tue, 3 May 2016 13:32:47 +0900 Subject: Make misc/measure.py compatible with python3 --- misc/measure.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/misc/measure.py b/misc/measure.py index 1323fc6..8ce95e6 100755 --- a/misc/measure.py +++ b/misc/measure.py @@ -17,6 +17,8 @@ """measure the runtime of a command by repeatedly running it. """ +from __future__ import print_function + import time import subprocess import sys @@ -24,7 +26,7 @@ import sys devnull = open('/dev/null', 'w') def run(cmd, repeat=10): - print 'sampling:', + print('sampling:', end=' ') sys.stdout.flush() samples = [] @@ -33,10 +35,10 @@ def run(cmd, repeat=10): subprocess.call(cmd, stdout=devnull, stderr=devnull) end = time.time() dt = (end - start) * 1000 - print '%dms' % int(dt), + print('%dms' % int(dt), end=' ') sys.stdout.flush() samples.append(dt) - print + print() # We're interested in the 'pure' runtime of the code, which is # conceptually the smallest time we'd see if we ran it enough times @@ -45,10 +47,10 @@ def run(cmd, repeat=10): # Also print how varied the outputs were in an attempt to make it # more obvious if something has gone terribly wrong. err = sum(s - best for s in samples) / float(len(samples)) - print 'estimate: %dms (mean err %.1fms)' % (best, err) + print('estimate: %dms (mean err %.1fms)' % (best, err)) if __name__ == '__main__': if len(sys.argv) < 2: - print 'usage: measure.py command args...' + print('usage: measure.py command args...') sys.exit(1) run(cmd=sys.argv[1:]) -- cgit v0.12