Last active
January 26, 2017 20:02
-
-
Save fxg42/55e968649261a37ac6ac to your computer and use it in GitHub Desktop.
Comparing Express, Phoenix, Rails, Flask, Grails and... PHP?
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
<?php | |
echo json_encode(array('hello'=>'world!')); | |
?> |
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
from flask import Flask | |
from flask import jsonify | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return jsonify(hello="world!") | |
if __name__ == "__main__": | |
app.run() |
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
class HelloController < ApplicationController | |
def index | |
render json:{"hello"=>"world!"} | |
end | |
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
class HelloController { | |
def index() { | |
render([ hello:"world!" ] as grails.converters.JSON) | |
} | |
} |
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
var express = require('express'); | |
var router = express.Router(); | |
router.get('/', function(req, res) { | |
res.json({hello:'world!'}); | |
}); | |
module.exports = router; |
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
defmodule HelloPhoenix.PageController do | |
use Phoenix.Controller | |
alias Poison, as: JSON | |
plug :action | |
def index(conn, _params) do | |
json conn, JSON.encode!(%{hello: "world!"}) | |
end | |
end |
Just a note: rails s
in the development environment runs a single-threaded server that has debugging tools enabled. It's not close to production performance or behavior.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I ran 100K queries first and than did a benchmark for 10k. The idea was to give any vm optimization a chance to run. In Grails' case, the first 10k queries were dealt with at a rate of 400 req/s. After 100k queries, the throughput jumped to about 1400 req/s -- possibly due to vm optimizations.