Class: MemoryFormatter
- Inherits:
-
RSpec::Core::Formatters::BaseTextFormatter
- Object
- RSpec::Core::Formatters::BaseTextFormatter
- MemoryFormatter
- Defined in:
- lib/memory_formatter.rb
Instance Method Summary collapse
- #dump_failures ⇒ Object
- #dump_summary ⇒ Object
- #example_passed(example) ⇒ Object (also: #example_failed, #example_pending)
- #example_started(example) ⇒ Object
-
#initialize ⇒ MemoryFormatter
constructor
A new instance of MemoryFormatter.
- #message ⇒ Object
Constructor Details
#initialize ⇒ MemoryFormatter
Returns a new instance of MemoryFormatter.
18 19 20 21 |
# File 'lib/memory_formatter.rb', line 18 def initialize(*) super @data = ProfileData.instance end |
Instance Method Details
#dump_failures ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/memory_formatter.rb', line 47 def dump_failures top = @data.top puts puts "Top #{top.count} most memory consumed:" top.values.each do |data| puts " #{data[:description]}" puts " #{color("%.3fMB" % [data[:end] - data[:start]], RSpec.configuration.failure_color)} #{data[:path]}" end end |
#dump_summary ⇒ Object
59 60 61 |
# File 'lib/memory_formatter.rb', line 59 def dump_summary(*) end |
#example_passed(example) ⇒ Object Also known as: example_failed, example_pending
40 41 42 |
# File 'lib/memory_formatter.rb', line 40 def example_passed(example) @data[example.object_id][:end] = NewRelic::Agent::Samplers::MemorySampler.new.sampler.get_sample end |
#example_started(example) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/memory_formatter.rb', line 27 def example_started(example) path = example.[:example_group][:file_path] line = example.[:line_number] @data[example.object_id] = { description: example..full_description, path: "#{path}:#{line}", start: NewRelic::Agent::Samplers::MemorySampler.new.sampler.get_sample } # super end |
#message ⇒ Object
23 24 25 |
# File 'lib/memory_formatter.rb', line 23 def (*) # do nothing end |