Created
October 3, 2011 15:41
-
-
Save ask/1259400 to your computer and use it in GitHub Desktop.
https://gist.github.com/1258543 re-implemented with http://eventlet.net/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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