kopia lustrzana https://github.com/micropython/micropython-lib
uasyncio: Add automated script for performance testing with Apache Bench.
rodzic
5601371cf0
commit
c1159a477e
|
@ -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
|
|
@ -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()
|
Ładowanie…
Reference in New Issue