diff options
author | KiYugadgeter <zyouhousikaku@gmail.com> | 2016-05-03 04:32:47 (GMT) |
---|---|---|
committer | KiYugadgeter <zyouhousikaku@gmail.com> | 2016-05-04 02:38:31 (GMT) |
commit | 28cedf169580f0b9847f2330a00dec9dd6041ab5 (patch) | |
tree | 8b56f6e21cffc8513876bf5934364a21d959f4eb | |
parent | e2de9d24fe9b7718c7cd6d00935c155463989487 (diff) | |
download | Ninja-28cedf169580f0b9847f2330a00dec9dd6041ab5.zip Ninja-28cedf169580f0b9847f2330a00dec9dd6041ab5.tar.gz Ninja-28cedf169580f0b9847f2330a00dec9dd6041ab5.tar.bz2 |
Make misc/measure.py compatible with python3
-rwxr-xr-x | misc/measure.py | 12 |
1 files 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:]) |