Sha256: 5fe38a72bd798a53113691c76803baa354e833b4f5debecba6d2748f14357ed5
Contents?: true
Size: 809 Bytes
Versions: 13
Compression:
Stored size: 809 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 { ActiveRecord::Base.uncached {(0...iterations).each { yield }} } end def compare_baseline baseline, timings, opts={} result_time = timings.map{|t| t.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
13 entries across 13 versions & 1 rubygems