Sha256: 49bf1931282f6a1acd0d19ad2698e79693d880b76d095c4eee1e82f077fefca2

Contents?: true

Size: 820 Bytes

Versions: 51

Compression:

Stored size: 820 Bytes

Contents

require Pathname.new(__FILE__).parent.to_s + '/post_run_logger'

module Marty; module RSpec; module PerformanceHelper
  include Marty::RSpec::PostRunLogger

  def calculate_baseline iterations
    Benchmark.measure do
      ActiveRecord::Base.uncached { (0...iterations).each { yield } }
    end
  end

  def compare_baseline baseline, timings, opts = {}
    result_time = timings.map(&:total).sum
    factor      = result_time / baseline.total

    lb = opts.delete(:lower_bound) || 1.5
    ub = opts.delete(:upper_bound) || 5.0

    post_run_log '  ' + '-' * 45,
                 '   baseline: %.2f, result: %.2f, factor: %.2f' %
                 [baseline.total, result_time, factor],
                 '  ' + '-' * 45

    expect(result_time).to be_between(baseline.total * lb, baseline.total * ub)
  end
end end end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
marty-14.3.0 spec/support/performance_helper.rb
marty-14.0.0 spec/support/performance_helper.rb
marty-13.0.2 spec/support/performance_helper.rb
marty-11.0.0 spec/support/performance_helper.rb
marty-10.0.3 spec/support/performance_helper.rb
marty-10.0.2 spec/support/performance_helper.rb
marty-10.0.0 spec/support/performance_helper.rb
marty-9.5.1 spec/support/performance_helper.rb
marty-9.5.0 spec/support/performance_helper.rb
marty-9.3.3 spec/support/performance_helper.rb
marty-9.3.2 spec/support/performance_helper.rb
marty-9.3.0 spec/support/performance_helper.rb
marty-8.5.0 spec/support/performance_helper.rb
marty-8.4.1 spec/support/performance_helper.rb
marty-8.3.1 spec/support/performance_helper.rb
marty-8.2.0 spec/support/performance_helper.rb
marty-8.0.0 spec/support/performance_helper.rb
marty-6.1.0 spec/support/performance_helper.rb
marty-5.2.0 spec/support/performance_helper.rb
marty-5.1.4 spec/support/performance_helper.rb