Class: TestProf::MemoryProf::Tracker::LinkedListNode
- Inherits:
-
Object
- Object
- TestProf::MemoryProf::Tracker::LinkedListNode
- Defined in:
- lib/test_prof/memory_prof/tracker/linked_list.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#memory_at_finish ⇒ Object
readonly
Returns the value of attribute memory_at_finish.
-
#memory_at_start ⇒ Object
readonly
Returns the value of attribute memory_at_start.
-
#nested_memory ⇒ Object
readonly
Returns the value of attribute nested_memory.
-
#previous ⇒ Object
readonly
Returns the value of attribute previous.
Instance Method Summary collapse
- #finish(memory_at_finish) ⇒ Object
- #hooks_memory ⇒ Object
-
#initialize(id:, item:, memory_at_start:, previous:) ⇒ LinkedListNode
constructor
A new instance of LinkedListNode.
- #total_memory ⇒ Object
Constructor Details
#initialize(id:, item:, memory_at_start:, previous:) ⇒ LinkedListNode
Returns a new instance of LinkedListNode.
81 82 83 84 85 86 87 88 89 |
# File 'lib/test_prof/memory_prof/tracker/linked_list.rb', line 81 def initialize(id:, item:, memory_at_start:, previous:) @id = id @item = item @previous = previous @memory_at_start = memory_at_start || 0 @memory_at_finish = nil @nested_memory = 0 end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
79 80 81 |
# File 'lib/test_prof/memory_prof/tracker/linked_list.rb', line 79 def id @id end |
#item ⇒ Object (readonly)
Returns the value of attribute item.
79 80 81 |
# File 'lib/test_prof/memory_prof/tracker/linked_list.rb', line 79 def item @item end |
#memory_at_finish ⇒ Object (readonly)
Returns the value of attribute memory_at_finish.
79 80 81 |
# File 'lib/test_prof/memory_prof/tracker/linked_list.rb', line 79 def memory_at_finish @memory_at_finish end |
#memory_at_start ⇒ Object (readonly)
Returns the value of attribute memory_at_start.
79 80 81 |
# File 'lib/test_prof/memory_prof/tracker/linked_list.rb', line 79 def memory_at_start @memory_at_start end |
#nested_memory ⇒ Object (readonly)
Returns the value of attribute nested_memory.
79 80 81 |
# File 'lib/test_prof/memory_prof/tracker/linked_list.rb', line 79 def nested_memory @nested_memory end |
#previous ⇒ Object (readonly)
Returns the value of attribute previous.
79 80 81 |
# File 'lib/test_prof/memory_prof/tracker/linked_list.rb', line 79 def previous @previous end |
Instance Method Details
#finish(memory_at_finish) ⇒ Object
107 108 109 110 111 |
# File 'lib/test_prof/memory_prof/tracker/linked_list.rb', line 107 def finish(memory_at_finish) @memory_at_finish = memory_at_finish previous&.add_nested(self) end |
#hooks_memory ⇒ Object
103 104 105 |
# File 'lib/test_prof/memory_prof/tracker/linked_list.rb', line 103 def hooks_memory total_memory - nested_memory end |
#total_memory ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/test_prof/memory_prof/tracker/linked_list.rb', line 91 def total_memory return 0 if memory_at_finish.nil? # It seems that on Windows Minitest may release a lot of memory to # the OS when it finishes and executes #report, leading to memory_at_finish # being less than memory_at_start. In this case we return nested_memory # which does not account for the memory used in `after` hooks, but it # is better than nothing. return nested_memory if memory_at_start > memory_at_finish memory_at_finish - memory_at_start end |