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
# File lib/perflab/benchmark.rb, line 43 def print_bmbm_improvement(results) existing_wall_time = results.find { |result| result.label == EXISTING }.real improved_wall_time = results.find { |result| result.label == IMPROVED }.real Util.print_performance_improvement(existing_wall_time, improved_wall_time) end