2011-09-03 20:26:57 -04:00
|
|
|
require 'bundler'
|
|
|
|
Bundler::GemHelper.install_tasks
|
2014-01-15 23:00:40 -05:00
|
|
|
|
2011-09-03 20:26:57 -04:00
|
|
|
require 'rspec/core/rake_task'
|
|
|
|
RSpec::Core::RakeTask.new(:spec)
|
2011-04-28 20:55:10 -04:00
|
|
|
task :test => :spec
|
2014-01-15 23:00:40 -05:00
|
|
|
|
|
|
|
begin
|
|
|
|
require 'rubocop/rake_task'
|
2014-06-03 13:52:08 -04:00
|
|
|
RuboCop::RakeTask.new
|
2014-01-15 23:00:40 -05:00
|
|
|
rescue LoadError
|
|
|
|
task :rubocop do
|
2014-06-03 13:52:08 -04:00
|
|
|
$stderr.puts 'RuboCop is disabled'
|
2014-01-15 23:00:40 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task :default => [:spec, :rubocop]
|
2014-10-01 14:41:24 -04:00
|
|
|
|
|
|
|
namespace :perf do
|
|
|
|
task :setup do
|
|
|
|
require 'omniauth'
|
|
|
|
require 'rack/test'
|
|
|
|
app = Rack::Builder.new do |b|
|
|
|
|
b.use Rack::Session::Cookie, :secret => 'abc123'
|
|
|
|
b.use OmniAuth::Strategies::Developer
|
|
|
|
b.run lambda { |_env| [200, {}, ['Not Found']] }
|
|
|
|
end.to_app
|
|
|
|
@app = Rack::MockRequest.new(app)
|
|
|
|
|
|
|
|
def call_app(path = ENV['GET_PATH'] || '/')
|
|
|
|
result = @app.get(path)
|
2017-02-12 01:12:28 -05:00
|
|
|
raise "Did not succeed #{result.body}" unless result.status == 200
|
2014-10-01 14:41:24 -04:00
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task :ips => :setup do
|
|
|
|
require 'benchmark/ips'
|
|
|
|
Benchmark.ips do |x|
|
|
|
|
x.report('ips') { call_app }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task :mem => :setup do
|
|
|
|
require 'memory_profiler'
|
|
|
|
num = Integer(ENV['CNT'] || 1)
|
|
|
|
report = MemoryProfiler.report do
|
|
|
|
num.times { call_app }
|
|
|
|
end
|
|
|
|
report.pretty_print
|
|
|
|
end
|
|
|
|
end
|