Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 28cedf1

Browse files
committed
Make misc/measure.py compatible with python3
1 parent e2de9d2 commit 28cedf1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

misc/measure.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717
"""measure the runtime of a command by repeatedly running it.
1818
"""
1919

20+
from __future__ import print_function
21+
2022
import time
2123
import subprocess
2224
import sys
2325

2426
devnull = open('/dev/null', 'w')
2527

2628
def run(cmd, repeat=10):
27-
print 'sampling:',
29+
print('sampling:', end=' ')
2830
sys.stdout.flush()
2931

3032
samples = []
@@ -33,10 +35,10 @@ def run(cmd, repeat=10):
3335
subprocess.call(cmd, stdout=devnull, stderr=devnull)
3436
end = time.time()
3537
dt = (end - start) * 1000
36-
print '%dms' % int(dt),
38+
print('%dms' % int(dt), end=' ')
3739
sys.stdout.flush()
3840
samples.append(dt)
39-
print
41+
print()
4042

4143
# We're interested in the 'pure' runtime of the code, which is
4244
# conceptually the smallest time we'd see if we ran it enough times
@@ -45,10 +47,10 @@ def run(cmd, repeat=10):
4547
# Also print how varied the outputs were in an attempt to make it
4648
# more obvious if something has gone terribly wrong.
4749
err = sum(s - best for s in samples) / float(len(samples))
48-
print 'estimate: %dms (mean err %.1fms)' % (best, err)
50+
print('estimate: %dms (mean err %.1fms)' % (best, err))
4951

5052
if __name__ == '__main__':
5153
if len(sys.argv) < 2:
52-
print 'usage: measure.py command args...'
54+
print('usage: measure.py command args...')
5355
sys.exit(1)
5456
run(cmd=sys.argv[1:])

0 commit comments

Comments
 (0)