Skip to content

Commit

Permalink
Merge branch 'schneems-schneems/perf-tasks'
Browse files Browse the repository at this point in the history
  • Loading branch information
tmilewski committed Feb 12, 2017
2 parents c6929fc + 0fd9fc4 commit 56d943e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -5,7 +5,9 @@ gem 'rake', '>= 12.0'
gem 'yard', '>= 0.9'

group :development do
gem 'benchmark-ips'
gem 'kramdown'
gem 'memory_profiler'
gem 'pry'
end

Expand Down
35 changes: 35 additions & 0 deletions Rakefile
Expand Up @@ -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)
raise "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

0 comments on commit 56d943e

Please sign in to comment.