Skip to content

Instantly share code, notes, and snippets.

@tomash
Created June 4, 2012 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomash/2871286 to your computer and use it in GitHub Desktop.
Save tomash/2871286 to your computer and use it in GitHub Desktop.
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
Copy link
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