Module: RSpec::Matchers::BeFasterThan
- Defined in:
- lib/should_be_faster.rb
Instance Method Summary collapse
- #faster_than(rhs_code, options = {}) ⇒ Object
- #slower_than(rhs_code, options = {}) ⇒ Object
- #times(*args) ⇒ Object
Instance Method Details
#faster_than(rhs_code, options = {}) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/should_be_faster.rb', line 72 def faster_than(rhs_code, ={}) ||= {} [:factor] = @factor Matcher.new(:faster_than) do [:faster] = true [:matcher] = self RSpec::Matchers::BenchmarkComparison.new(rhs_code, ).benchmark_comparison end end |
#slower_than(rhs_code, options = {}) ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/should_be_faster.rb', line 82 def slower_than(rhs_code, ={}) ||= {} [:factor] = @factor Matcher.new(:slower_than) do [:faster] = false [:matcher] = self RSpec::Matchers::BenchmarkComparison.new(rhs_code, ).benchmark_comparison end end |
#times(*args) ⇒ Object
67 68 69 70 |
# File 'lib/should_be_faster.rb', line 67 def times(*args) @factor = args[0] self end |