diff --git a/uasyncio/benchmark/test-boom-heavy.sh b/uasyncio/benchmark/test-boom-heavy.sh new file mode 100755 index 00000000..a977806a --- /dev/null +++ b/uasyncio/benchmark/test-boom-heavy.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# +# This in one-shot scripts to test "heavy load" uasyncio HTTP server using +# Boom tool https://github.com/tarekziade/boom . +# +# Note that this script doesn't test performance, but rather test functional +# correctness of uasyncio server implementation, while serving large amounts +# of data (guaranteedly more than a socket buffer). Thus, this script should +# not be used for benchmarking. +# + +if [ ! -d .venv-boom ]; then + virtualenv .venv-boom + . .venv-boom/bin/activate + # PyPI currently has 0.8 which is too old + #pip install boom + pip install git+https://github.com/tarekziade/boom +else + . .venv-boom/bin/activate +fi + + +micropython -X heapsize=300000000 -O test_http_server_heavy.py & +sleep 1 + +PYTHONPATH=. boom -n1000 -c30 http://localhost:8081 --post-hook=boom_uasyncio.validate + +kill %1 diff --git a/uasyncio/benchmark/test_http_server_heavy.py b/uasyncio/benchmark/test_http_server_heavy.py new file mode 100644 index 00000000..65a4d4eb --- /dev/null +++ b/uasyncio/benchmark/test_http_server_heavy.py @@ -0,0 +1,39 @@ +import uasyncio as asyncio +import signal +import errno + + +cnt = 0 + +@asyncio.coroutine +def serve(reader, writer): + global cnt + #s = "Hello.\r\n" + s = "Hello. %07d\r\n" % cnt + cnt += 1 + yield from reader.read() + yield from writer.awrite("HTTP/1.0 200 OK\r\n\r\n") + try: + yield from writer.awrite(s) + yield from writer.awrite(s * 100) + yield from writer.awrite(s * 400000) + yield from writer.awrite("=== END ===") + yield from writer.close() + except OSError as e: + if e.args[0] == errno.EPIPE: + print("EPIPE") + elif e.args[0] == errno.ECONNRESET: + print("ECONNRESET") + else: + raise + + +import logging +logging.basicConfig(level=logging.INFO) +#logging.basicConfig(level=logging.DEBUG) +signal.signal(signal.SIGPIPE, signal.SIG_IGN) +loop = asyncio.get_event_loop() +mem_info() +loop.call_soon(asyncio.start_server(serve, "0.0.0.0", 8081, backlog=100)) +loop.run_forever() +loop.close()