summaryrefslogtreecommitdiff
path: root/spec/integration/omniauth/Rakefile
blob: c611f39414346e8e56a956c4a753660aebdf4826 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

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)
      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.hold!('../../../tmp/omniauth_benchmark.json')
      x.report('before') { call_app }
      x.report('after') { call_app }

      x.compare!
    end
  end
end