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:
commit
d292a1647a
2 changed files with 37 additions and 0 deletions
2
Gemfile
2
Gemfile
|
@ -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
|
||||
|
|
35
Rakefile
35
Rakefile
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue