Class: Minitest::HogReporter
- Inherits:
-
Reporter
- Object
- Reporter
- Minitest::HogReporter
- Defined in:
- lib/minitest/hog.rb
Defined Under Namespace
Classes: Record
Instance Attribute Summary collapse
-
#max_memory ⇒ Object
readonly
Returns the value of attribute max_memory.
-
#piggy_tests ⇒ Object
readonly
Returns the value of attribute piggy_tests.
Instance Method Summary collapse
-
#initialize(io = STDOUT, options = {}) ⇒ HogReporter
constructor
A new instance of HogReporter.
- #record(result) ⇒ Object
- #report ⇒ Object
Constructor Details
#initialize(io = STDOUT, options = {}) ⇒ HogReporter
Returns a new instance of HogReporter.
43 44 45 46 47 48 |
# File 'lib/minitest/hog.rb', line 43 def initialize(io = STDOUT, = {}) super @max_memory = .fetch(:max_memory, 64) @piggy_tests = [] end |
Instance Attribute Details
#max_memory ⇒ Object (readonly)
Returns the value of attribute max_memory.
41 42 43 |
# File 'lib/minitest/hog.rb', line 41 def max_memory @max_memory end |
#piggy_tests ⇒ Object (readonly)
Returns the value of attribute piggy_tests.
41 42 43 |
# File 'lib/minitest/hog.rb', line 41 def piggy_tests @piggy_tests end |
Instance Method Details
#record(result) ⇒ Object
50 51 52 53 54 |
# File 'lib/minitest/hog.rb', line 50 def record result if result.memory_used > max_memory piggy_tests << Record.new(result.location, result.memory_used) end end |
#report ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/minitest/hog.rb', line 56 def report return if piggy_tests.empty? piggy_tests.sort_by!{|r| -r.memory_used} io.puts io.puts "#{piggy_tests.length} hogs." piggy_tests.each_with_index do |record, i| io.puts "%3d) %s: %i kb" % [i+1, record.location, record.memory_used] end end |