Sha256: 43a29441fd17755fe0e1a22f9933429544d336cbd0a5c450012d8a36978249c7

Contents?: true

Size: 734 Bytes

Versions: 25

Compression:

Stored size: 734 Bytes

Contents

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

require 'flipper'
require 'flipper/adapters/memory'

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

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

  total = 1_000
  enabled = []
  disabled = []

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

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

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

puts "percentage: Actual vs Hoped For"

[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

25 entries across 25 versions & 1 rubygems

Version Path
flipper-0.11.0.beta6 examples/percentage_of_time.rb
flipper-0.11.0.beta5 examples/percentage_of_time.rb
flipper-0.11.0.beta4 examples/percentage_of_time.rb
flipper-0.11.0.beta3 examples/percentage_of_time.rb
flipper-0.11.0.beta1 examples/percentage_of_time.rb
flipper-0.10.2 examples/percentage_of_time.rb
flipper-0.10.1 examples/percentage_of_time.rb
flipper-0.10.0 examples/percentage_of_time.rb
flipper-0.9.2 examples/percentage_of_time.rb
flipper-0.9.1 examples/percentage_of_time.rb
flipper-0.9.0 examples/percentage_of_time.rb
flipper-0.9.0.beta1 examples/percentage_of_time.rb
flipper-0.8.0 examples/percentage_of_time.rb
flipper-0.7.5 examples/percentage_of_time.rb
flipper-0.7.4 examples/percentage_of_time.rb
flipper-0.7.3 examples/percentage_of_time.rb
flipper-0.7.2 examples/percentage_of_time.rb
flipper-0.7.1 examples/percentage_of_time.rb
flipper-0.7.0 examples/percentage_of_time.rb
flipper-0.7.0.beta6 examples/percentage_of_time.rb