Class: PerfLab::Benchmark
- Inherits:
-
Object
- Object
- PerfLab::Benchmark
- Defined in:
- lib/perflab/benchmark.rb
Constant Summary collapse
- EXISTING =
'existing'.freeze
- IMPROVED =
'improved'.freeze
Class Method Summary collapse
- .bmbm(improved, existing = nil) ⇒ Object
- .ips(improved, existing = nil) ⇒ Object
- .ipsa(improved, existing = nil) ⇒ Object
Class Method Details
.bmbm(improved, existing = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# 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) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# 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) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# 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 |