@@ -0,0 +1,1187 @@
+#!/usr/bin/env python%0A#%0A# A simple benchmark of the tornado.gen module.%0A# Runs in two modes, testing new-style (@coroutine and Futures)%0A# and old-style (@engine and Tasks) coroutines.%0A%0Afrom timeit import Timer%0A%0Afrom tornado import gen%0Afrom tornado.options import options, define, parse_command_line%0A%0Adefine('num', default=10000, help='number of iterations')%0A%0A# These benchmarks are delicate.  They hit various fast-paths in the gen%0A# machinery in order to stay synchronous so we don't need an IOLoop.%0A# This removes noise from the results, but it's easy to change things%0A# in a way that completely invalidates the results.%0A%0A@gen.engine%0Adef e2(callback):%0A    callback()%0A%0A@gen.engine%0Adef e1():%0A    for i in range(10):%0A        yield gen.Task(e2)%0A%0A@gen.coroutine%0Adef c2():%0A    pass%0A%0A@gen.coroutine%0Adef c1():%0A    for i in range(10):%0A        yield c2()%0A%0Adef main():%0A    parse_command_line()%0A    t = Timer(e1)%0A    results = t.timeit(options.num) / options.num%0A    print 'engine: %250.3f ms per iteration' %25 (results * 1000)%0A    t = Timer(c1)%0A    results = t.timeit(options.num) / options.num%0A    print 'coroutine: %250.3f ms per iteration' %25 (results * 1000)%0A%0Aif __name__ == '__main__':%0A    main()%0A

Add a benchmark for coroutine processing.