From 84135eac5bd6d1d02f3adeb8620bd99083ea4915 Mon Sep 17 00:00:00 2001 From: Hakan Ensari Date: Thu, 22 Nov 2012 13:25:14 +0000 Subject: [PATCH] Run benchmark specs optionally --- spec/benchmark_spec.rb | 42 ++++++++++++++++++++++-------------------- spec/helper.rb | 2 +- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/spec/benchmark_spec.rb b/spec/benchmark_spec.rb index cc385bc..91c9286 100644 --- a/spec/benchmark_spec.rb +++ b/spec/benchmark_spec.rb @@ -2,34 +2,36 @@ require_relative 'helper' require 'rack/test' require 'app' -describe 'benchmark the app' do - include Rack::Test::Methods +if ENV['BENCH'] + describe 'benchmark the app' do + include Rack::Test::Methods - let(:app) { Sinatra::Application } + let(:app) { Sinatra::Application } - bench_performance_constant 'latest' do - 100.times do - get '/latest' + bench_performance_constant 'latest' do + 100.times do + get '/latest' + end end - end - bench_performance_constant 'latest base' do - 100.times do - get '/latest?base=USD' + bench_performance_constant 'latest base' do + 100.times do + get '/latest?base=USD' + end end - end - bench_performance_constant 'historical' do - 100.times do - random_date = Date.today - rand(4000) - get "/#{random_date}" + bench_performance_constant 'historical' do + 100.times do + random_date = Date.today - rand(4000) + get "/#{random_date}" + end end - end - bench_performance_constant 'historical base' do - 100.times do - random_date = Date.today - rand(4000) - get "/#{random_date}?base=USD" + bench_performance_constant 'historical base' do + 100.times do + random_date = Date.today - rand(4000) + get "/#{random_date}?base=USD" + end end end end diff --git a/spec/helper.rb b/spec/helper.rb index cb2658e..5230bd2 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -1,3 +1,3 @@ require 'minitest/autorun' -require 'minitest/benchmark' +require 'minitest/benchmark' if ENV['BENCH'] require 'minitest/pride'