Sha256: 21d19574bc591078f31e6902fd9440472f28fa40f47c1270f7acbef9c998778f

Contents?: true

Size: 720 Bytes

Versions: 16

Compression:

Stored size: 720 Bytes

Contents

require File.expand_path('../example_setup', __FILE__)

require 'flipper'

adapter = Flipper::Adapters::Memory.new
flipper = Flipper.new(adapter)
logging = flipper[:logging]

perform_test = lambda do |number|
  logging.enable flipper.time(number)

  total = 100_000
  enabled = []
  disabled = []

  enabled = (1..total).map { |n|
    logging.enabled? ? true : nil
  }.compact

  actual = (enabled.size / total.to_f * 100).round(3)

  # puts "#{enabled.size} / #{total}"
  puts "percentage: #{actual.to_s.rjust(6, ' ')} vs #{number.to_s.rjust(3, ' ')}"
end

puts "percentage: Actual vs Hoped For"

[0.001, 0.01, 0.1, 1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 99, 100].each do |number|
  perform_test.call number
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
flipper-0.20.4 examples/percentage_of_time.rb
flipper-0.20.3 examples/percentage_of_time.rb
flipper-0.20.2 examples/percentage_of_time.rb
flipper-0.20.1 examples/percentage_of_time.rb
flipper-0.20.0 examples/percentage_of_time.rb
flipper-0.20.0.beta3 examples/percentage_of_time.rb
flipper-0.20.0.beta2 examples/percentage_of_time.rb
flipper-0.20.0.beta1 examples/percentage_of_time.rb
flipper-0.19.1 examples/percentage_of_time.rb
flipper-0.19.0 examples/percentage_of_time.rb
flipper-0.18.0 examples/percentage_of_time.rb
flipper-0.17.2 examples/percentage_of_time.rb
flipper-0.17.1 examples/percentage_of_time.rb
flipper-0.16.2 examples/percentage_of_time.rb
flipper-0.16.1 examples/percentage_of_time.rb
flipper-0.16.0 examples/percentage_of_time.rb