From 9b6a9082b3f259527f858a3bada86db932d921b7 Mon Sep 17 00:00:00 2001 From: Hakan Ensari Date: Wed, 21 Nov 2012 18:17:38 +0000 Subject: [PATCH] Benchmark endpoints --- spec/benchmark_spec.rb | 35 +++++++++++++++++++++++++++++++++++ spec/helper.rb | 1 + 2 files changed, 36 insertions(+) create mode 100644 spec/benchmark_spec.rb diff --git a/spec/benchmark_spec.rb b/spec/benchmark_spec.rb new file mode 100644 index 0000000..cc385bc --- /dev/null +++ b/spec/benchmark_spec.rb @@ -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 diff --git a/spec/helper.rb b/spec/helper.rb index 3274fe8..cb2658e 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -1,2 +1,3 @@ require 'minitest/autorun' +require 'minitest/benchmark' require 'minitest/pride'