声明:int getrusage(int who, struct rusage *usage);
getrusage 函数返回当前的资源使用情况。当who 参数为 RUSAGE_SELF 时,返回当前进程的资源使用情况;为 RUSAGE_CHILDREN 时,返回状态为终止或者等待的子进程使用的资源情况。
返回的结果存在结构体 struct rusage 中:
struct rusage { struct timeval ru_utime; /* user time used 用户态使用的时间 */ struct timeval ru_stime; /* system time used 内核态使用的时间 */ long ru_maxrss; /* maximum resident set size */ long ru_ixrss; /* integral shared memory size */ long ru_idrss; /* integral unshared data size */ long ru_isrss; /* integral unshared stack size */ long ru_minflt; /* page reclaims */ long ru_majflt; /* page faults */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary context switches */ };
原文地址:http://blog.csdn.net/topasstem8/article/details/40821929