class PerfLab::Benchmark

Constants

EXISTING
IMPROVED

Public Class Methods

bmbm(improved, existing = nil) click to toggle source
# File lib/perflab/benchmark.rb, line 7
def bmbm(improved, existing = nil)
  results = ::Benchmark.bmbm do |x|
    x.report(EXISTING) { existing.call } if existing.present?
    x.report(IMPROVED) { improved.call }
  end

  return results unless existing.present?

  print_bmbm_improvement(results)
  results
end
ips(improved, existing = nil) click to toggle source
# File lib/perflab/benchmark.rb, line 19
def ips(improved, existing = nil)
  ::Benchmark.ips do |x|
    x.config(warmup: 1, time: 1)

    x.report(EXISTING) { existing.call } if existing.present?
    x.report(IMPROVED) { improved.call }

    x.compare!
  end
end
ipsa(improved, existing = nil) click to toggle source
# File lib/perflab/benchmark.rb, line 30
def ipsa(improved, existing = nil)
  ::Benchmark.ipsa do |x|
    x.config(warmup: 1, time: 1)

    x.report(EXISTING) { existing.call } if existing.present?
    x.report(IMPROVED) { improved.call }

    x.compare!
  end
end

Private Class Methods

print_bmbm_improvement(results) click to toggle source