Skip to content

Instantly share code, notes, and snippets.

@TakesxiSximada
Last active June 30, 2020 05:49
Show Gist options
  • Save TakesxiSximada/1a1b0bbe1e3917a865c92d0b95a0e247 to your computer and use it in GitHub Desktop.
Save TakesxiSximada/1a1b0bbe1e3917a865c92d0b95a0e247 to your computer and use it in GitHub Desktop.
Benchmark Tools

Benchmark Tools

Execute benchmark command

curl

example-curl.sh

Apache bench

example-ab.sh

Dummy server

python slow.py
N=1000
C=3
NAME=0
URL=http://127.0.0.1:8000
ab -e outout-$N-$C-$NAME.csv -n $N -c $C -H "Content-Type: application/json" -p request_data.json $URL
URL=http://127.0.0.1:8000
METHOD=POST
curl -d @request_data.json -H "Content-Type: application/json" -X $METHOD $URL
#----------
[formatters]
keys=access
[formatter_access]
class=uvicorn.logging.AccessFormatter
format=%(levelprefix)s %(status_code)s - "%(request_line)s"
#---------
[handlers]
keys=console
[handler_console]
class=StreamHandler
level=DEBUG
formatter=access
args=(sys.stdout,)
#--------
[loggers]
keys=root
[logger_root]
level=DEBUG
handlers=console
propagate=False
import asyncio
import responder
import uvicorn
api = responder.API()
@api.route("/{greeting}")
async def greet_world(req, resp, *, greeting):
await asyncio.sleep(10)
resp.media = {}
if __name__ == '__main__':
api.run(port=9997, timeout_keep_alive=10000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment