Skip to content

Instantly share code, notes, and snippets.

@ask
Created October 3, 2011 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ask/1259400 to your computer and use it in GitHub Desktop.
Save ask/1259400 to your computer and use it in GitHub Desktop.
import eventlet
from eventlet import wsgi
from eventlet import sleep
def switch(it):
for item in it:
yield item
sleep(0.0)
def _fib(n):
a, b = 0, 1
for i in xrange(n):
yield a
a, b = b, a + b
def fibonacci(n):
return list(switch(_fib(n)))
def simple_app(environ, start_response):
print("START RESPONSE")
start_response('200 OK', [('Content-Type', 'text/plain')])
r = repr(fibonacci(40))
print("FIB(40): %r" % (r, ))
return [r]
print "Serving on port 8000..."
wsgi.server(eventlet.listen(('', 8000)), simple_app)
---
$ ab -n 10 -c 5 http://127.0.0.1:8000/
...
Requests per second: 0.03 [#/sec] (mean)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment