summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2016-05-04 10:25:11 -0400
committerNico Weber <nicolasweber@gmx.de>2016-05-04 10:25:11 -0400
commit63a8584b069a32b871237fc80dcb4c397b863ef7 (patch)
tree8b56f6e21cffc8513876bf5934364a21d959f4eb
parente2de9d24fe9b7718c7cd6d00935c155463989487 (diff)
parent28cedf169580f0b9847f2330a00dec9dd6041ab5 (diff)
downloadninja-63a8584b069a32b871237fc80dcb4c397b863ef7.tar.gz
Merge pull request #1150 from KiYugadgeter/python3_measure
Make misc/measure.py compatible with python3
-rwxr-xr-xmisc/measure.py12
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:])