Benchmark endpoints

This commit is contained in:
Hakan Ensari 2012-11-21 18:17:38 +00:00
parent 4b5c870e15
commit 9b6a9082b3
2 changed files with 36 additions and 0 deletions

35
spec/benchmark_spec.rb Normal file
View File

@ -0,0 +1,35 @@
require_relative 'helper'
require 'rack/test'
require 'app'
describe 'benchmark the app' do
include Rack::Test::Methods
let(:app) { Sinatra::Application }
bench_performance_constant 'latest' do
100.times do
get '/latest'
end
end
bench_performance_constant 'latest base' do
100.times do
get '/latest?base=USD'
end
end
bench_performance_constant 'historical' do
100.times do
random_date = Date.today - rand(4000)
get "/#{random_date}"
end
end
bench_performance_constant 'historical base' do
100.times do
random_date = Date.today - rand(4000)
get "/#{random_date}?base=USD"
end
end
end

View File

@ -1,2 +1,3 @@
require 'minitest/autorun'
require 'minitest/benchmark'
require 'minitest/pride'