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
|
2017-12-27 13:18:31 -05:00
|
|
|
warn 'RuboCop is disabled'
|
2014-01-15 23:00:40 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-28 13:07:45 -04:00
|
|
|
task :default => %i[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
|