frankfurter/spec/benchmark_spec.rb

38 lines
749 B
Ruby
Raw Normal View History

2012-11-21 19:17:38 +01:00
require_relative 'helper'
require 'rack/test'
require 'app'
2012-11-22 14:25:14 +01:00
if ENV['BENCH']
describe 'benchmark the app' do
include Rack::Test::Methods
2012-11-21 19:17:38 +01:00
2012-11-22 14:25:14 +01:00
let(:app) { Sinatra::Application }
2012-11-21 19:17:38 +01:00
2012-11-22 14:25:14 +01:00
bench_performance_constant 'latest' do
100.times do
get '/latest'
end
2012-11-21 19:17:38 +01:00
end
2012-11-22 14:25:14 +01:00
bench_performance_constant 'latest base' do
100.times do
get '/latest?base=USD'
end
2012-11-21 19:17:38 +01:00
end
2012-11-22 14:25:14 +01:00
bench_performance_constant 'historical' do
100.times do
random_date = Date.today - rand(4000)
get "/#{random_date}"
end
2012-11-21 19:17:38 +01:00
end
2012-11-22 14:25:14 +01:00
bench_performance_constant 'historical base' do
100.times do
random_date = Date.today - rand(4000)
get "/#{random_date}?base=USD"
end
2012-11-21 19:17:38 +01:00
end
end
end