File: instrumentation_ips.rb

package info (click to toggle)
ruby-flipper 0.26.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,288 kB
  • sloc: ruby: 16,377; sh: 61; javascript: 24; makefile: 14
file content (21 lines) | stat: -rw-r--r-- 652 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'bundler/setup'
require 'flipper'
require 'active_support/notifications'
require 'active_support/isolated_execution_state'
require 'benchmark/ips'

class FlipperSubscriber
  def call(name, start, finish, id, payload)
  end

  ActiveSupport::Notifications.subscribe(/flipper/, new)
end

actor = Flipper::Actor.new("User;1")
bare = Flipper.new(Flipper::Adapters::Memory.new)
instrumented = Flipper.new(Flipper::Adapters::Memory.new, instrumenter: ActiveSupport::Notifications)

Benchmark.ips do |x|
  x.report("with instrumentation") { instrumented.enabled?(:foo, actor) }
  x.report("without instrumentation") { bare.enabled?(:foo, actor) }
end