diff --git a/bench/flask_plaintext.py b/bench/flask_plaintext.py deleted file mode 100644 index ecf9ee3..0000000 --- a/bench/flask_plaintext.py +++ /dev/null @@ -1,14 +0,0 @@ -import logging -logging.basicConfig() -logging.getLogger().setLevel(logging.CRITICAL) - -from flask import Flask -from waitress import serve - -app = Flask(__name__) - -@app.route('/') -def index(): - return "Hello, World!" - -serve(app, host='0.0.0.0', port=8000) diff --git a/bench/socketify_plaintext.py b/bench/socketify_plaintext.py index 36192e4..6c70297 100644 --- a/bench/socketify_plaintext.py +++ b/bench/socketify_plaintext.py @@ -1,13 +1,25 @@ from socketify import App +import os +import multiprocessing + +def run_app(): + app = App() + app.get("/", lambda res, req: res.end("Hello, World!")) + app.listen(8000, lambda config: print("PID %d Listening on port http://localhost:%d now\n" % (os.getpid(), config.port))) + app.run() + +def create_fork(): + n = os.fork() + # n greater than 0 means parent process + if not n > 0: + run_app() + +# fork limiting the cpu count - 1 +for i in range(1, multiprocessing.cpu_count()): + create_fork() + +run_app() # run app on the main process too :) + + -app = App() -app.get("/", lambda res, req: res.end("Hello World!")) -app.listen(8000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port)) -app.run() -# 124943.00 req/s socketify.py - PyPy3 7.3.9 -# 70877.75 req/s socketify.py - Python 3.10.7 -# 30173.75 req/s gunicorn 20.1.0 + uvicorn 0.19.0 - Python 3.10.7 -# 17580.25 req/s gunicorn 20.1.0 + uvicorn 0.19.0 - PyPy3 7.3.9 -# 8044.50 req/s flask 2.1.2 PyPy 7.3.9 -# 1957.50 req/s flask 2.1.2 Python 3.10.7 diff --git a/bench/uvicorn_guvicorn_plaintext.py b/bench/uvicorn_guvicorn_plaintext.py index 9335f42..d01f167 100644 --- a/bench/uvicorn_guvicorn_plaintext.py +++ b/bench/uvicorn_guvicorn_plaintext.py @@ -14,4 +14,5 @@ async def app(scope, receive, send): }) #python3 -m gunicorn uvicorn_guvicorn_plaintext:app -w 1 -k uvicorn.workers.UvicornWorker -#pypy3 -m gunicorn uvicorn_guvicorn_plaintext:app -w 1 -k uvicorn.workers.UvicornWorker \ No newline at end of file +#pypy3 -m gunicorn uvicorn_guvicorn_plaintext:app -w 1 -k uvicorn.workers.UvicornWorker + diff --git a/misc/bench-bar-graph.png b/misc/bench-bar-graph.png new file mode 100644 index 0000000..55f1400 Binary files /dev/null and b/misc/bench-bar-graph.png differ diff --git a/misc/bench-bar-graph.svg b/misc/bench-bar-graph.svg new file mode 100644 index 0000000..8128701 --- /dev/null +++ b/misc/bench-bar-graph.svg @@ -0,0 +1 @@ +1 process2 process4 processfalconfalconpypyuvicornuviconpypysocketifysocketifypypy050,000100,000150,000libraryrequests/s \ No newline at end of file