test/benchmarks/benchmark.rake
def measure_configure_memory
    require 'memory_profiler'
    # warmup
    3.times { Coverband.configure }

    previous_out = $stdout
    capture = StringIO.new
    $stdout = capture

    MemoryProfiler.report do
      10.times do
        Coverband.configure do |config|
          redis_url = ENV['CACHE_REDIS_URL'] || ENV['REDIS_URL']
          config.store = Coverband::Adapters::RedisStore.new(Redis.new(url: redis_url), redis_namespace: 'coverband_bench_data')
        end
      end
    end.pretty_print
    data = $stdout.string
    $stdout = previous_out
    unless data.match('Total retained:  0 bytes')
      puts data
      raise 'leaking memory!!!'
    end
  ensure
    $stdout = previous_out
  end
###
# TODO: This currently fails, as it holds a string in redis adapter
# but really Coverband shouldn't be configured multiple times and the leak is small
# not including in test suite but we can try to figure it out and fix.
###
This currently fails, as it holds a string in redis adapter
but really Coverband shouldn't be configured multiple times and the leak is small
not including in test suite but we can try to figure it out and fix.
This currently fails as it holds a string in redis adapter but really Coverband shouldn ' t be configured multiple times and the leak is small not including in test suite but we can try to figure it out and fix .
def measure_configure_memory
    require 'memory_profiler'
    3.times { Coverband.configure }
    previous_out = $stdout
    capture = StringIO.new
    $stdout = capture
    MemoryProfiler.report do
      10.times do
        Coverband.configure do |config|
          redis_url = ENV['CACHE_REDIS_URL'] || ENV['REDIS_URL']
          config.store = Coverband::Adapters::RedisStore.new(Redis.new(url: redis_url), redis_namespace: 'coverband_bench_data')
        end
      end
    end.pretty_print
    data = $stdout.string
    $stdout = previous_out
    unless data.match('Total retained:  0 bytes')
      puts data
      raise 'leaking memory!!!'
    end
  ensure
    $stdout = previous_out
  end
def measure_configure_memory require 'memory_profiler' 3 . times { Coverband . configure } previous_out = $stdout capture = StringIO . new $stdout = capture MemoryProfiler . report do 10 . times do Coverband . configure do | config | redis_url = ENV [ 'CACHE_REDIS_URL' ] || ENV [ 'REDIS_URL' ] config . store = Coverband :: Adapters :: RedisStore . new ( Redis . new ( url : redis_url ) , redis_namespace : 'coverband_bench_data' ) end end end . pretty_print data = $stdout . string $stdout = previous_out unless data . match ( 'Total retained:  0 bytes' ) puts data raise 'leaking memory!!!' end ensure $stdout = previous_out end
TODO: This currently fails, as it holds a string in redis adapter
but really Coverband shouldn't be configured multiple times and the leak is small
not including in test suite but we can try to figure it out and fix.
TODO : This currently fails as it holds a string in redis adapter but really Coverband shouldn ' t be configured multiple times and the leak is small not including in test suite but we can try to figure it out and fix .
# warmup