Lua版nodeのluvitと本家nodeのベンチマークをとってみました。ベンチマークに使ったのは双方のサイトのトップページに掲載されている”Hello world”を返すというごくごく単純なものです。
■ベンチマークに使ったコード
node
1 2 3 4 5 6 |
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello world\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); |
luvit
1 2 3 4 5 6 7 8 9 10 |
local http = require("http") http.createServer(function (req, res) local body = "Hello world\n" res:writeHead(200, { ["Content-Type"] = "text/plain", ["Content-Length"] = #body }) res:finish(body) end):listen(1338) print("Server listening at http://127.0.0.1:1338/") |
■結果
ベンチマークにはabを使いました。
1 |
ab -c 1000 -n 100000 http://127.0.0.1:1337/ |
10回程度ベンチマークを取りましたが、いずれも同じ傾向で、luvitのほうか1.3〜1.5倍程度多くのリクエスを捌いていました。
node
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
Concurrency Level: 1000 Time taken for tests: 12.757 seconds Complete requests: 100000 Failed requests: 0 Write errors: 0 Total transferred: 11300000 bytes HTML transferred: 1200000 bytes Requests per second: 7839.10 [#/sec] (mean) Time per request: 127.566 [ms] (mean) Time per request: 0.128 [ms] (mean, across all concurrent requests) Transfer rate: 865.06 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 62 337.0 0 7012 Processing: 10 32 36.5 25 2864 Waiting: 10 32 36.5 25 2864 Total: 24 93 349.3 25 7046 Percentage of the requests served within a certain time (ms) 50% 25 66% 31 75% 32 80% 37 90% 48 95% 58 98% 1034 99% 1247 100% 7046 (longest request) |
luvit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
Concurrency Level: 1000 Time taken for tests: 8.460 seconds Complete requests: 100000 Failed requests: 0 Write errors: 0 Total transferred: 12900000 bytes HTML transferred: 1200000 bytes Requests per second: 11820.37 [#/sec] (mean) Time per request: 84.600 [ms] (mean) Time per request: 0.085 [ms] (mean, across all concurrent requests) Transfer rate: 1489.09 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 62 359.0 0 7012 Processing: 0 13 38.1 11 2010 Waiting: 0 13 38.1 11 2010 Total: 2 76 368.7 11 7034 Percentage of the requests served within a certain time (ms) 50% 11 66% 13 75% 15 80% 15 90% 17 95% 31 98% 1014 99% 1223 100% 7034 (longest request) |