]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
some modifications in demos/benchmark so it can run both in py2 and py3 1327/head
authorJoseph <josephok@qq.com>
Fri, 6 Feb 2015 02:29:13 +0000 (10:29 +0800)
committerJoseph <josephok@qq.com>
Fri, 6 Feb 2015 02:29:13 +0000 (10:29 +0800)
demos/benchmark/benchmark.py
demos/benchmark/gen_benchmark.py
demos/benchmark/stack_context_benchmark.py
demos/benchmark/template_benchmark.py

index 218ab8ed7f3c8b72d512b1376156795819513c19..6a0354d35f5f471f408101b5b1794ffc94394a52 100755 (executable)
@@ -22,6 +22,11 @@ import random
 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)
index adbe44fc8fe07023c840a598b29a186dab868600..1b5281fb9d16f3b3004a8618ba7c87128383ea9e 100644 (file)
@@ -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()
index 57c7dd22607c24069cd0ef3a7e618d8eec9adc58..43d003c291e423e1337d93431372da212a402aba 100755 (executable)
@@ -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__':
index a38c689c93c3b2c8934818dca94851fd33b7a2c3..1114b1f4e32db45a5a5d93e2154b03f3f5361373 100755 (executable)
@@ -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()