From c1159a477e529df1b42c661f907018f7d38eb7cc Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 12 Nov 2014 23:43:13 +0200 Subject: [PATCH] uasyncio: Add automated script for performance testing with Apache Bench. --- uasyncio/benchmark/test-ab-light.sh | 12 +++++++++++ uasyncio/benchmark/test_http_server_light.py | 21 ++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 uasyncio/benchmark/test-ab-light.sh create mode 100644 uasyncio/benchmark/test_http_server_light.py diff --git a/uasyncio/benchmark/test-ab-light.sh b/uasyncio/benchmark/test-ab-light.sh new file mode 100755 index 00000000..bf929862 --- /dev/null +++ b/uasyncio/benchmark/test-ab-light.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# +# This in one-shot scripts to test "light load" uasyncio HTTP server using +# Apache Bench (ab). +# + +micropython -O test_http_server_light.py & +sleep 1 + +ab -n10000 -c100 http://localhost:8081/ + +kill %1 diff --git a/uasyncio/benchmark/test_http_server_light.py b/uasyncio/benchmark/test_http_server_light.py new file mode 100644 index 00000000..48befebd --- /dev/null +++ b/uasyncio/benchmark/test_http_server_light.py @@ -0,0 +1,21 @@ +import uasyncio as asyncio + + +@asyncio.coroutine +def serve(reader, writer): + #print(reader, writer) + #print("================") + yield from reader.read() + yield from writer.awrite("HTTP/1.0 200 OK\r\n\r\nHello.\r\n") + yield from writer.close() + #print("Finished processing request") + + +import logging +#logging.basicConfig(level=logging.INFO) +logging.basicConfig(level=logging.DEBUG) +loop = asyncio.get_event_loop() +mem_info() +loop.call_soon(asyncio.start_server(serve, "127.0.0.1", 8081, backlog=100)) +loop.run_forever() +loop.close()