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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
same sinatra environment but ran on thin, not webrick: