Skip to content

Commit

Permalink
Merge pull request #1327 from josephok/master
Browse files Browse the repository at this point in the history
some modifications in demos/benchmark so it can run both in py2 and py3
  • Loading branch information
bdarnell committed Feb 7, 2015
2 parents 30631d4 + c34b4f7 commit db88a65
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions demos/benchmark/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
import signal
import subprocess

try:
xrange
except NameError:
xrange = range

# choose a random port to avoid colliding with TIME_WAIT sockets left over
# from previous runs.
define("min_port", type=int, default=8000)
Expand Down
4 changes: 2 additions & 2 deletions demos/benchmark/gen_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def main():
parse_command_line()
t = Timer(e1)
results = t.timeit(options.num) / options.num
print 'engine: %0.3f ms per iteration' % (results * 1000)
print('engine: %0.3f ms per iteration' % (results * 1000))
t = Timer(c1)
results = t.timeit(options.num) / options.num
print 'coroutine: %0.3f ms per iteration' % (results * 1000)
print('coroutine: %0.3f ms per iteration' % (results * 1000))

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion demos/benchmark/stack_context_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def main():
'ExceptionBenchmark().call_wrapped(500)',
]
for cmd in cmds:
print cmd
print(cmd)
subprocess.check_call(base_cmd + [cmd])

if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions demos/benchmark/template_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ def render():
def main():
parse_command_line()
if options.dump:
print tmpl.code
print(tmpl.code)
sys.exit(0)
t = Timer(render)
results = t.timeit(options.num) / options.num
print '%0.3f ms per iteration' % (results*1000)
print('%0.3f ms per iteration' % (results*1000))

if __name__ == '__main__':
main()

0 comments on commit db88a65

Please sign in to comment.