diff --git a/Dockerfile b/Dockerfile index c9a3022..d0cbeed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ ENV GOPATH /usr/go/ RUN DEBIAN_FRONTEND=noninteractive \ apt-get update && apt-get install -y \ autoconf automake libtool build-essential \ - python3 python3-pip git nodejs golang gosu + python3 python3-pip git nodejs golang gosu curl RUN pip3 install vex RUN vex --python=python3.5 -m bench pip install -U pip @@ -30,6 +30,10 @@ RUN vex bench pip --cache-dir=/var/lib/cache/pip \ RUN vex bench pip freeze -r /usr/src/servers/requirements.txt +RUN curl -L https://github.com/luvit/lit/raw/master/get-lit.sh | sh +RUN ./lit make lit://luvit/luvit +RUN install -t /usr/bin -m 0755 ./luvit + EXPOSE 25000 VOLUME /var/lib/cache diff --git a/run_benchmarks b/run_benchmarks index ea1b4ef..77a3ece 100755 --- a/run_benchmarks +++ b/run_benchmarks @@ -30,6 +30,7 @@ server_base = ['docker', 'run', '--rm', '-t', '-p', '25000:25000', python = ['vex', 'bench', 'python'] nodejs = ['nodejs'] +luvit = ['luvit'] echo_client = ['./echo_client', '--output-format=json'] @@ -147,6 +148,12 @@ benchmarks = [{ '--streams', '--uvloop'], 'server_address': unix_address, 'client': unix_client, +}, { + 'name': 'tcpecho-luvit', + 'title': 'TCP echo server (luvit)', + 'server': luvit + ['/usr/src/servers/luvitecho.lua'], + 'server_address': tcp_address, + 'client': tcp_client, }, { 'name': 'http-asyncio-aiohttp', 'title': 'HTTP server (asyncio/aiohttp)', @@ -191,6 +198,12 @@ benchmarks = [{ 'server': ['/usr/src/servers/gohttp'], 'server_address': tcp_address, 'client': http_client, +}, { + 'name': 'http-luvit', + 'title': 'HTTP server (luvit)', + 'server': luvit + ['/usr/src/servers/luvit_http_server.lua'], + 'server_address': tcp_address, + 'client': http_client, }] diff --git a/servers/luvit_http_server.lua b/servers/luvit_http_server.lua new file mode 100644 index 0000000..b23ec5e --- /dev/null +++ b/servers/luvit_http_server.lua @@ -0,0 +1,23 @@ +local http = require('http') +local url = require('url') + +responses = {} + +http.createServer(function (req, res) + req.uri = url.parse(req.url) + local msize = 1024 + local path = req.uri.pathname + if string.len(path) > 1 then + msize = tonumber(string.sub(path, 2)) + end + + if not responses[msize] then + responses[msize] = string.rep("X", msize) + end + + res:setHeader("Content-Type", "text/plain") + res:setHeader("Content-Length", msize) + res:finish(responses[msize]) +end):listen(25000, '0.0.0.0') + +print('Server running at http://127.0.0.1:25000/') \ No newline at end of file diff --git a/servers/luvitecho.lua b/servers/luvitecho.lua new file mode 100644 index 0000000..35e25d2 --- /dev/null +++ b/servers/luvitecho.lua @@ -0,0 +1,27 @@ +local uv = require('uv') + +-- Create listener socket +local server = uv.new_tcp() +server:bind('0.0.0.0', 25000) + +server:listen(128, function(err) + -- Create socket handle for client + local client = uv.new_tcp() + + -- Accept incoming connection + server:accept(client) + + -- Relay data back to client + client:read_start(function(err, data) + if err then + client:close() + return + end + + if data then + client:write(data) + else + client:close() + end + end) +end) \ No newline at end of file