summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMichael Herold <michael.j.herold@gmail.com>2017-02-24 06:36:59 -0600
committerMichael Herold <michael.j.herold@gmail.com>2017-02-24 07:11:34 -0600
commit9f77380ddbc72347063065d9e9f7c4a13cd504d5 (patch)
treea500eb248c99e1b1e691bb1a164238a8c5c819ed /spec
parentc071e4f9fdcd41b078e6be405f9cf54480b76c8e (diff)
downloadhashie-9f77380ddbc72347063065d9e9f7c4a13cd504d5.tar.gz
Add performance benchmarks for Mash
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/omniauth/Gemfile2
-rw-r--r--spec/integration/omniauth/Rakefile29
2 files changed, 31 insertions, 0 deletions
diff --git a/spec/integration/omniauth/Gemfile b/spec/integration/omniauth/Gemfile
index cbb4b87..4221e7f 100644
--- a/spec/integration/omniauth/Gemfile
+++ b/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'
diff --git a/spec/integration/omniauth/Rakefile b/spec/integration/omniauth/Rakefile
new file mode 100644
index 0000000..4e0c11f
--- /dev/null
+++ b/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