Sha256: 9e382140d0f2cf4b613f8ef70cd9f685fec176b750803b7ed41d9f54b20262a5
Contents?: true
Size: 783 Bytes
Versions: 1
Compression:
Stored size: 783 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.random(number) total = 1_000 enabled = [] disabled = [] (1..total).each do |number| if logging.enabled? enabled << number else disabled << number end end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flipper-0.4.0 | examples/percentage_of_random.rb |