1
0
Fork 0
mirror of https://github.com/omniauth/omniauth.git synced 2022-11-09 12:31:49 -05:00

Merge branch 'schneems/perf-tasks' of https://github.com/schneems/omniauth into schneems-schneems/perf-tasks

This commit is contained in:
Tom Milewski 2017-02-12 01:07:57 -05:00
commit d292a1647a
No known key found for this signature in database
GPG key ID: 0C45B110F8B40F20
2 changed files with 37 additions and 0 deletions

View file

@ -7,6 +7,8 @@ gem 'yard', '>= 0.9'
group :development do
gem 'kramdown'
gem 'pry'
gem 'benchmark-ips'
gem 'memory_profiler'
end
group :test do

View file

@ -15,3 +15,38 @@ rescue LoadError
end
task :default => [:spec, :rubocop]
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)
fail "Did not succeed #{result.body}" unless result.status == 200
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