Created
June 4, 2012 22:45
-
-
Save tomash/2871286 to your computer and use it in GitHub Desktop.
vibe.d vs sinatra, a meaningless microbenchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"] | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// microwebapp microbenchmark, ruby/sinatra version | |
require 'rubygems' | |
require 'sinatra' | |
get '/' do | |
erb :index | |
end | |
get '/:id' do | |
erb :show | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Example page</title> | |
</head> | |
<body> | |
<p>Hello world!</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Param show page</title> | |
</head> | |
<body> | |
<p><%= params[:id] %></p> | |
</body> | |
</html> |
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)
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.
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
ruby 1.9.2-p290, sinatra 1.3.2, production mode: