class RSpec::Benchmark::ComplexityMatcher::Matcher

@api public
Implements the ‘perform`

def actual

def actual
  @trend
end

def description

Other tags:
    Api: - private
def description
  "perform #{@fit_type}"
end

def failure_message

Other tags:
    Api: - private
def failure_message
  "expected block to #{description}, but #{failure_reason}"
end

def failure_message_when_negated

def failure_message_when_negated
  "expected block not to #{description}, but #{failure_reason}"
end

def failure_reason

def failure_reason
  "performed #{actual}"
end

def in_range(start, limit = (not_set = true))

Other tags:
    Api: - public
def in_range(start, limit = (not_set = true))
  case start
  when Array
    @start, *, @limit = *start
    @ratio = start[1] / start[0]
  when Numeric
    @start, @limit = start, limit
  else
    raise ArgumentError,
        "Wrong range argument '#{start}', it expects an array or numeric start value."
  end
  self
end

def initialize(fit_type, **options)

def initialize(fit_type, **options)
  @fit_type  = fit_type
  @threshold = options.fetch(:threshold) {
                RSpec::Benchmark.configuration.fit_quality }
  @repeat    = options.fetch(:repeat) {
                RSpec::Benchmark.configuration.samples }
  @start     = 8
  @limit     = 8 << 10
  @ratio     = 8
end

def matcher_name

def matcher_name
  "perform_#{@fit_type}"
end

def matches?(block)

Other tags:
    Api: - private

Returns:
  • (Boolean) -
def matches?(block)
  range = ::Benchmark::Trend.range(@start, @limit, ratio: @ratio)
  @trend, trends = ::Benchmark::Trend.infer_trend(range, repeat: @repeat, &block)
  threshold = trends[@trend][:residual]
  @trend == @fit_type && threshold >= @threshold
end

def ratio(ratio)

def ratio(ratio)
  @ratio = ratio
  self
end

def sample(repeat)

def sample(repeat)
  @repeat = repeat
  self
end

def supports_block_expectations?

Other tags:
    Api: - private

Returns:
  • (True) -
def supports_block_expectations?
  true
end

def threshold(threshold)

def threshold(threshold)
  @threshold = threshold
  self
end

def times

Other tags:
    Api: - public
def times
  self
end