A proof of concept of having Sinatra like routes inside your controllers.
Since the router is gone, feel free to remove config/routes.rb
.
Then add the file below to lib/action_controller/inline_routes.rb
inside your app.
# You will need fswatch installed (available in homebrew and friends) | |
# The command below will run tests and wait until fswatch writes something. | |
# The --stale flag will only run stale entries, it requires Elixir v1.3. | |
fswatch lib/ test/ | mix test --stale --listen-on-stdin |
# Elixir v1.0 | |
defmodule Rules do | |
defmacro __using__(_) do | |
quote do | |
import unquote(__MODULE__) | |
@before_compile unquote(__MODULE__) | |
@rules [] | |
end | |
end |
I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.
Framework | Throughput (req/s) | Latency (ms) | Consistency (σ ms) |
---|
This is just an exercise to measure the performance between Sinatra-like libraries in:
Elixir v0.4.dev (running on top of the Erlang VM R14B03) with Dynamo;
Ruby 1.9.2 with [Sinatra Synchrony] v0.0.3 (https://github.com/kyledrake/sinatra-synchrony) + Thin;
node.js 0.4.7 with [express] v2.3.10(https://github.com/visionmedia/express)
small_int_list = Enum.to_list(1..10) | |
medium_int_list = Enum.to_list(1..1000) | |
large_int_list = Enum.to_list(1..100_000) | |
small_other_int_list = Enum.to_list(11..20) | |
medium_other_int_list = Enum.to_list(1001..2000) | |
large_other_int_list = Enum.to_list(100_001..200_000) | |
small_bin_list = Enum.map(1..10, fn _ -> :crypto.strong_rand_bytes(10) end) | |
medium_bin_list = Enum.map(1..1000, fn _ -> :crypto.strong_rand_bytes(10) end) |
// Improvements to file uploads with Zombie. | |
// | |
// Just start the Sinatra server below and run this file with node. | |
// Depending on the server used with Sinatra, it will fail upfront or forward | |
// a bad request to the app. The source code in zombie is in the link below | |
// (you will need Zombie from git, you can check it out and use `npm link`): | |
// | |
// https://github.com/assaf/zombie/blob/master/src/zombie/history.coffee#L93 | |
// | |
var zombie = require("zombie"); |
source :rubygems | |
gem "ruby-prof" |
defmodule Chat.Client do | |
# In all of the following functions 'server' stands for the server's pid | |
def join(server) do | |
send server, :join | |
end | |
def say(server, message) do | |
send server, { :say, message } | |
end |