Module: TWPipeline::Rusage
- Defined in:
- lib/twpipeline/rusage.rb,
sig/twpipeline.rbs
Constant Summary collapse
- SELF =
0- CHILDREN =
-1
- MAXRSS_OFFSET =
Fiddle::SIZEOF_LONG * 4
- SCALE =
RUBY_PLATFORM.include?("darwin") ? 1 : 1024
Class Method Summary collapse
Class Method Details
.available? ⇒ Boolean
13 |
# File 'lib/twpipeline/rusage.rb', line 13 def available? = !getrusage.nil? |
.max_rss(who) ⇒ ::Integer
15 16 17 18 19 20 21 22 |
# File 'lib/twpipeline/rusage.rb', line 15 def max_rss(who) return 0 unless available? buffer = Fiddle::Pointer.malloc(Fiddle::SIZEOF_LONG * 32, Fiddle::RUBY_FREE) return 0 unless getrusage.call(who, buffer).zero? buffer[MAXRSS_OFFSET, Fiddle::SIZEOF_LONG].unpack1("l!") * SCALE end |