Class: Yardstick::MeasurementSet

Inherits:
OrderedSet show all
Defined in:
lib/yardstick/measurement_set.rb

Overview

A set of yardstick measurements

Instance Method Summary collapse

Methods inherited from OrderedSet

#<<, #each, #empty?, #include?, #index, #initialize, #length, #merge

Constructor Details

This class inherits a constructor from Yardstick::OrderedSet

Instance Method Details

#coverageInteger, Rational

The percentage of successful measurements

Examples:

coverage = measurements.coverage  # => Rational(561, 570)
'%.1f%%' % (coverage * 100)       # => "98.4%"

Returns:

  • (Integer, Rational)

    the coverage percentage



55
56
57
# File 'lib/yardstick/measurement_set.rb', line 55

def coverage
  empty? ? 1 : Rational(successful, total)
end

#failedInteger

The number of failed measurements

Examples:

measurements.failed  # => 9

Returns:

  • (Integer)

    failed measurements



41
42
43
# File 'lib/yardstick/measurement_set.rb', line 41

def failed
  total - successful
end

#puts(io = $stdout) ⇒ undefined

Warn the unsuccessful measurements and a summary

Examples:

measurements.puts  # (outputs measurements results and summary)

Parameters:

  • io (#puts) (defaults to: $stdout)

    optional object to puts the summary

Returns:

  • (undefined)


70
71
72
73
# File 'lib/yardstick/measurement_set.rb', line 70

def puts(io = $stdout)
  each { |measurement| measurement.puts(io) }
  puts_summary(io)
end

#successfulInteger

The number of successful measurements

Examples:

measurements.successful  # => 561

Returns:

  • (Integer)

    successful measurements



28
29
30
# File 'lib/yardstick/measurement_set.rb', line 28

def successful
  select { |measurement| measurement.ok? }.length
end

#totalInteger

The total number of measurements

Examples:

measurements.total  # => 570

Returns:

  • (Integer)

    total measurements



15
16
17
# File 'lib/yardstick/measurement_set.rb', line 15

def total
  length
end