-
-
Notifications
You must be signed in to change notification settings - Fork 33
Top
Daniel Berger edited this page Apr 28, 2023
·
3 revisions
The sys-proctable also comes with a Sys::Top
class. It contains a single class method, top
. By default this will return an array of the top 10 processes using the pctcpu
(percent CPU) field.
# Use the defaults
Sys::Top.top
# Return the top 5 processes only
Sys::Top.top(5)
# Return the top 5 processes using the `rss` field
Sys::Top.top(5, :rss)
By default, MacOS and AIX will use the pid number instead of pctcpu
. You can, of course, alter this behavior by specifying the field you would like to use as the second argument to the top
method.