Skip to content

Instantly share code, notes, and snippets.

@asvetlov
Created March 30, 2018 16:13
Show Gist options
  • Save asvetlov/13295efdc1301bea241d7d35496e6f81 to your computer and use it in GitHub Desktop.
Save asvetlov/13295efdc1301bea241d7d35496e6f81 to your computer and use it in GitHub Desktop.
Simple aiohttp performance check
stop `run_server.sh` after wrk has finished, install snakeviz (`pip install snakeviz`) and run it
`snakeviz out.prof`
# Run with python3 simple_server.py PORT
from aiohttp import web
import asyncio
import sys
import uvloop
import logging
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
async def handle(request):
return web.Response(body=b'OK')
app = web.Application()
app.add_routes([web.get('/', handle)])
logging.basicConfig(level=logging.DEBUG)
web.run_app(app, port=sys.argv[1], access_log=None)
python -m cProfile -o out.prof run_aiohttp.py 8080
wrk -t 10 http://localhost:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment