Module: Perfer::Platform::POSIX
Defined Under Namespace
Modules: LibC
Classes: RUsageStruct, TimeValStruct
Constant Summary
collapse
- PID =
Process.pid
Instance Method Summary
collapse
Instance Method Details
#command_line ⇒ Object
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/perfer/platform/posix.rb', line 70
def command_line
return Rubinius::OS_ARGV.join(' ') if defined? Rubinius::OS_ARGV
case OS
when /^darwin/, /^linux/, /^solaris/
`ps -o args= -p #{PID}`.lines.to_a.last.rstrip
else
warn "Unknown platform for Platform.command_line: #{os.inspect}"
nil
end
end
|
#maximum_memory_used ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/perfer/platform/posix.rb', line 51
def maximum_memory_used
rusage = RUsageStruct.new
r = LibC.getrusage(LibC::RUSAGE_SELF, rusage)
if r != 0
warn "Could not retrieve memory information with getrusage(2)"
0
else
m = rusage[:ru_maxrss]
warn "Memory information with getrusage(2) is inaccurate, ru_maxrss was 0" if m == 0
if /darwin/ =~ OS
m else
m * 1024 end
end
ensure
rusage.pointer.free if rusage
end
|
#memory_used ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/perfer/platform/posix.rb', line 41
def memory_used
case OS
when /^darwin/, /^linux/, /^solaris/
Integer(`ps -o rss= -p #{PID}`) * 1024
else
warn "Unknown platform for Platform.command_line: #{os.inspect}"
nil
end
end
|