#include <sys/resource.h>
/* Return resource usage information on process indicated by WHO
and put it in *USAGE. Returns 0 for success, -1 for failure. */
extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;
參數:
who:可能選擇有
RUSAGE_SELF:獲取當前進程的資源使用信息。
RUSAGE_CHILDREN:獲取子進程的資源使用信息。
usage:指向存放資源使用信息的結構指針
#include <bits/resources.>
/* Structure which says how much of each resource has been used. */
struct rusage
{
?/* Total amount of user time used. */
?struct timeval ru_utime;
?/* Total amount of system time used. */
?struct timeval ru_stime;
?/* Maximum resident set size (in kilobytes). */
?long int ru_maxrss;
?/* Amount of sharing of text segment memory
?with other processes (kilobyte-seconds). */
?long int ru_ixrss;
?/* Amount of data segment memory used (kilobyte-seconds). */
?long int ru_idrss;
?/* Amount of stack memory used (kilobyte-seconds). */
?long int ru_isrss;
?/* Number of soft page faults (i.e. those serviced by reclaiming
?a page from the list of pages awaiting reallocation. */
?long int ru_minflt;
?/* Number of hard page faults (i.e. those that required I/O). */
?long int ru_majflt;
?/* Number of times a process was swapped out of physical memory. */
?long int ru_nswap;
?/* Number of input operations via the file system. Note: This
?and `ru_oublock' do not include operations with the cache. */
?long int ru_inblock;
?/* Number of output operations via the file system. */
?long int ru_oublock;
?/* Number of IPC messages sent. */
?long int ru_msgsnd;
?/* Number of IPC messages received. */
?long int ru_msgrcv;
?/* Number of signals delivered. */
long int ru_nsignals;
/* Number of voluntary context switches, i.e. because the process
gave up the process before it had to (usually to wait for some
resource to be available). */
long int ru_nvcsw;
/* Number of involuntary context switches, i.e. a higher priority process
became runnable or the current process used up its time slice. */
?long int ru_nivcsw;
?};
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
