Skip to content

Commit

Permalink
Add performance benchmarks for Mash
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelherold committed Feb 24, 2017
1 parent c071e4f commit 9f77380
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
15 changes: 15 additions & 0 deletions benchmarks/mash_method_access.rb
@@ -0,0 +1,15 @@
$LOAD_PATH.unshift('lib')

require 'hashie'
require 'benchmark/ips'

mash = Hashie::Mash.new(test: 'value')

Benchmark.ips do |x|
x.hold!('tmp/mash_benchmark.json')

x.report('before') { mash.test }
x.report('after') { mash.test }

x.compare!
end
2 changes: 2 additions & 0 deletions spec/integration/omniauth/Gemfile
@@ -1,7 +1,9 @@
source 'http://rubygems.org'

gem 'benchmark-ips'
gem 'hashie', path: '../../..'
gem 'omniauth', '~> 1.4.1'
gem 'sinatra'
gem 'rake'
gem 'rspec', '~> 3.5.0'
gem 'rack-test', '~> 0.6.3'
29 changes: 29 additions & 0 deletions spec/integration/omniauth/Rakefile
@@ -0,0 +1,29 @@
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 ->(_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.hold!('../../../tmp/omniauth_benchmark.json')
x.report('before') { call_app }
x.report('after') { call_app }

x.compare!
end
end
end

0 comments on commit 9f77380

Please sign in to comment.