Class: Minitest::ShellPs
- Inherits:
-
Object
- Object
- Minitest::ShellPs
- Defined in:
- lib/minitest/hog.rb
Overview
Return the resident set size (RSS) in kB.
This is fairly foolproof, but probably not the most accurate measure possible since shelling out most likely affects memory usage and isn’t terribly efficient.
Other strategies could be implemented in the future, for instance see NewRelic’s samplers: github.com/newrelic/rpm/blob/release/lib/new_relic/agent/samplers/memory_sampler.rb
Instance Method Summary collapse
-
#call ⇒ Object
Based off of: zogovic.com/post/59091704817/memory-usage-monitor-in-ruby Example ps output: “ RSSn223124n”.
-
#initialize(pid = Process::pid) ⇒ ShellPs
constructor
A new instance of ShellPs.
Constructor Details
#initialize(pid = Process::pid) ⇒ ShellPs
Returns a new instance of ShellPs.
78 79 80 |
# File 'lib/minitest/hog.rb', line 78 def initialize(pid = Process::pid) @pid = pid end |
Instance Method Details
#call ⇒ Object
Based off of: zogovic.com/post/59091704817/memory-usage-monitor-in-ruby Example ps output: “ RSSn223124n”
84 85 86 |
# File 'lib/minitest/hog.rb', line 84 def call `ps -o rss -p #{@pid}`.split("\n").last.to_i end |