Skip to content

Instantly share code, notes, and snippets.

@tomash tomash/app.d
Created Jun 4, 2012

Embed
What would you like to do?
vibe.d vs sinatra, a meaningless microbenchmark
// microwebapp microbenchmark, D/vibe version
import vibe.d;
void index(HttpServerRequest req, HttpServerResponse res)
{
res.renderCompat!("index.dt")();
}
void show(HttpServerRequest req, HttpServerResponse res)
{
res.renderCompat!("show.dt",
HttpServerRequest, "req")
(Variant(req));
}
static this()
{
auto routes = new UrlRouter;
routes.get("/:id", &show);
routes.get("/", &index);
auto settings = new HttpServerSettings;
settings.port = 8080;
listenHttp(settings, routes);
}
/* index.dt:
!!! 5
html
head
title Example page
body
p Hello world
*/
/* show.dt:
!!! 5
html
head
title User show page
body
p= req.params["id"]
*/
// microwebapp microbenchmark, ruby/sinatra version
require 'rubygems'
require 'sinatra'
get '/' do
erb :index
end
get '/:id' do
erb :show
end
<html>
<head>
<title>Example page</title>
</head>
<body>
<p>Hello world!</p>
</body>
</html>
<html>
<head>
<title>Param show page</title>
</head>
<body>
<p><%= params[:id] %></p>
</body>
</html>
@tomash

This comment has been minimized.

Copy link
Owner Author

tomash commented Jun 4, 2012

ruby 1.9.2-p290, sinatra 1.3.2, production mode:

tomek@tomek-U36SD:~/d_apps/vibench$ ab -n 1000 -c 20 http://localhost:4567/

Server Software:        WEBrick/1.3.1
Server Hostname:        localhost
Server Port:            4567

Document Path:          /
Document Length:        109 bytes

Concurrency Level:      20
Time taken for tests:   6.507 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      354000 bytes
HTML transferred:       109000 bytes
Requests per second:    153.67 [#/sec] (mean)
Time per request:       130.147 [ms] (mean)
Time per request:       6.507 [ms] (mean, across all concurrent requests)
Transfer rate:          53.13 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   10  99.4      0     999
Processing:    16  119  37.3    122     368
Waiting:        7  115  38.5    119     362
Total:         16  129 112.9    122    1367

Percentage of the requests served within a certain time (ms)
  50%    122
  66%    135
  75%    142
  80%    148
  90%    162
  95%    173
  98%    194
  99%   1071
 100%   1367 (longest request)
@tomash

This comment has been minimized.

Copy link
Owner Author

tomash commented Jun 4, 2012

DMD v2.059, vibe.d 0.7.3



tomek@tomek-U36SD:~/d_apps/vibench$ ab -n 40000 -c 800 http://localhost:8080/

Server Software:        vibe.d/0.7.3
Server Hostname:        localhost
Server Port:            8080

Document Path:          /
Document Length:        128 bytes

Concurrency Level:      800
Time taken for tests:   4.747 seconds
Complete requests:      40000
Failed requests:        0
Write errors:           0
Total transferred:      10960000 bytes
HTML transferred:       5120000 bytes
Requests per second:    8425.85 [#/sec] (mean)
Time per request:       94.946 [ms] (mean)
Time per request:       0.119 [ms] (mean, across all concurrent requests)
Transfer rate:          2254.57 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   21 141.6      0    1001
Processing:     5   28 181.9      8    4719
Waiting:        5   28 181.9      8    4719
Total:          7   48 298.9      8    4720

Percentage of the requests served within a certain time (ms)
  50%      8
  66%      8
  75%      8
  80%      9
  90%     12
  95%     13
  98%   1006
  99%   1675
 100%   4720 (longest request)
@tomash

This comment has been minimized.

Copy link
Owner Author

tomash commented Jun 4, 2012

please bear in mind that these benchmarks were quick, dirty, lots of things that might be wrong here and basically should be taken with a grain of salt.

@tomash

This comment has been minimized.

Copy link
Owner Author

tomash commented Jun 5, 2012

same sinatra environment but ran on thin, not webrick:

tomek@tomek-U36SD:~/sinatra_apps$ ab -n 10000 -c 200 http://localhost:3000/

Server Software:        thin
Server Hostname:        localhost
Server Port:            3000

Document Path:          /
Document Length:        109 bytes

Concurrency Level:      200
Time taken for tests:   6.149 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      3140000 bytes
HTML transferred:       1090000 bytes
Requests per second:    1626.27 [#/sec] (mean)
Time per request:       122.981 [ms] (mean)
Time per request:       0.615 [ms] (mean, across all concurrent requests)
Transfer rate:          498.68 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   23 159.9      0    3001
Processing:    18   76 136.1     65    3377
Waiting:        5   71 136.2     61    3372
Total:         18   99 252.3     65    4374

Percentage of the requests served within a certain time (ms)
  50%     65
  66%     66
  75%     68
  80%     71
  90%     75
  95%     88
  98%   1060
  99%   1086
 100%   4374 (longest request)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.