Skip to content

Instantly share code, notes, and snippets.

@pmashchak
Last active December 18, 2015 20:19
Show Gist options
  • Save pmashchak/b1a14855a194f3335677 to your computer and use it in GitHub Desktop.
Save pmashchak/b1a14855a194f3335677 to your computer and use it in GitHub Desktop.
Faraday_Manticore_Test
class TestController < ApplicationController
skip_before_action :verify_authenticity_token
def index
json = { first_name: 'Jonh', last_name: 'Smith', address: '10 Greenwood Ave, Garden, MI, 15006', age: '25', status: 'married' }
render json: json, status: :ok
end
end
if __FILE__ == $0
require 'rubygems'
require 'faraday'
require 'manticore'
require 'benchmark'
require 'faraday/adapter/manticore'
host = 'http://localhost:8080'
route = '/test'
body = { name: 'Victor', last_name: 'Smith' }
faraday = Faraday.new(host)
faraday_m = Faraday.new(host) do |f|
f.adapter :manticore
end
manticore = Manticore::Client.new
iterations = 1000
Benchmark.bm(27) do |x|
x.report('Faraday Get: ') { iterations.times { faraday.get(route).status } }
x.report('Faraday (M) Get:') { iterations.times { faraday_m.get(route).status } }
x.report('Manticore Get: ') { iterations.times { manticore.get(host + route).code } }
x.report('Manticore Post: ') { iterations.times { manticore.post(host + route, params: body).code } }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment