Created
January 25, 2012 23:17
-
-
Save tiegz/1679603 to your computer and use it in GitHub Desktop.
Rails 3 vs Grape benchmark
This file contains hidden or 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
# config/routes.rb | |
mount MyGrapeAPI => "/grape_api" | |
namespace :api do | |
namespace :v1 do | |
resources :projects | |
end | |
end | |
####################### | |
##### RAILS 3 API ##### | |
####################### | |
# app/controllers/api/v1/base_controller.rb | |
class Api::V1::BaseController < ActionController::Base | |
respond_to :json | |
end | |
# app/controllers/api/v1/projects_controller.rb | |
class Api::V1::ProjectsController < Api::V1::BaseController | |
def index | |
respond_with Project.new | |
end | |
end | |
##################### | |
##### GRAPE API ##### | |
##################### | |
# app/middleware/my_grape_api.rb | |
class MyGrapeAPI < Grape::API | |
version 'v1' | |
resources :projects do | |
get "/" do | |
Project.new | |
end | |
end | |
end | |
# Apache Bench commands: 1000 requests, 50 concurrent requests | |
# ab -n 1000 -c 50 -g "grape_api.data" http://api.local/grape_api/v1/projects.json | |
# ab -n 1000 -c 50 -g "rails_3_api.data" http://api.local/api/v1/projects.json |
many thanks , cheers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can u share the local results please here so you can give us an indicator ?