日期:2014-05-16 浏览次数:20728 次
#include <sys/resource> int getrusage(int who, struct rusage *r_usage);
struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ long ru_maxrss; #define ru_first ru_ixrss long ru_ixrss; /* XXX: 0 */ long ru_idrss; /* XXX: sum of rm_asrss */ long ru_isrss; /* XXX: 0 */ long ru_minflt; /* any page faults not requiring I/O */ long ru_majflt; /* any page faults requiring I/O */ 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 " */ #define ru_last ru_nivcsw };
int who = RUSAGE_SELF; struct rusage usage; int ret; ret = getrusage(who, &usage);