uasyncio: Add automated script for performance testing with Apache Bench.

pull/13/merge
Paul Sokolovsky 2014-11-12 23:43:13 +02:00
rodzic 5601371cf0
commit c1159a477e
2 zmienionych plików z 33 dodań i 0 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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()