Class: PerfLab::Operator
- Inherits:
-
Object
- Object
- PerfLab::Operator
- Defined in:
- lib/perflab/operator.rb
Instance Method Summary collapse
- #bmbm ⇒ Object
- #bmbm_improved ⇒ Object
- #correct? ⇒ Boolean
-
#initialize(existing:, improved:, equality:) ⇒ Operator
constructor
A new instance of Operator.
- #ips ⇒ Object
- #ips_improved ⇒ Object
- #ipsa ⇒ Object
- #ipsa_improved ⇒ Object
- #profile ⇒ Object
- #profile_existing ⇒ Object
Constructor Details
#initialize(existing:, improved:, equality:) ⇒ Operator
Returns a new instance of Operator.
3 4 5 6 7 |
# File 'lib/perflab/operator.rb', line 3 def initialize(existing:, improved:, equality:) @existing = existing @improved = improved @equality = equality end |
Instance Method Details
#bmbm ⇒ Object
25 26 27 |
# File 'lib/perflab/operator.rb', line 25 def bmbm Benchmark.bmbm(@improved, @existing) end |
#bmbm_improved ⇒ Object
29 30 31 |
# File 'lib/perflab/operator.rb', line 29 def bmbm_improved Benchmark.bmbm(@improved) end |
#correct? ⇒ Boolean
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/perflab/operator.rb', line 49 def correct? if @equality.present? result = @equality.call(@existing.call, @improved.call) raise ArgumentError, 'Equality must return a boolean' unless [TrueClass, FalseClass].include?(result.class) result else @existing.call == @improved.call end end |
#ips ⇒ Object
33 34 35 |
# File 'lib/perflab/operator.rb', line 33 def ips Benchmark.ips(@improved, @existing) end |
#ips_improved ⇒ Object
37 38 39 |
# File 'lib/perflab/operator.rb', line 37 def ips_improved Benchmark.ipsa(@improved) end |
#ipsa ⇒ Object
41 42 43 |
# File 'lib/perflab/operator.rb', line 41 def ipsa Benchmark.ipsa(@improved, @existing) end |
#ipsa_improved ⇒ Object
45 46 47 |
# File 'lib/perflab/operator.rb', line 45 def ipsa_improved Benchmark.ipsa(@improved) end |