print?#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>
#include <time.h>
#include <unistd.h>
int main(void)
{
while(1)
{
struct rusage ru;
memset(&ru, 0, sizeof(struct rusage));
getrusage(RUSAGE_SELF, &ru);
printf("ou/inblock:%ld,%ld,snd/rcvmsg:%ld,%ld,max/ix/idrss:%ld,%ld,%ld,min/majflt:%ld,%ld,signal:%ld,nv/nivcsw:%ld,%ld,swap:%ld,utime:%lu,%lu,stime:%lu,%lu\r\n",
ru.ru_oublock, ru.ru_inblock,
ru.ru_msgsnd, ru.ru_msgrcv,
ru.ru_maxrss, ru.ru_ixrss, ru.ru_idrss,
ru.ru_minflt, ru.ru_majflt,
ru.ru_nsignals,
ru.ru_nvcsw, ru.ru_nivcsw,
ru.ru_nswap,
ru.ru_utime.tv_usec, ru.ru_utime.tv_sec,
ru.ru_stime.tv_usec, ru.ru_stime.tv_sec);
/*
ru_oublock: 塊輸出操作
ru_inblock: 塊輸入操作
ru_msgsnd: 發送的message
ru_msgrcv: 收到的message
ru_maxrss: 最大駐留集大小
ru_ixrss: 全部共享內存大小
ru_idrss:全部非共享內存大小
ru_minflt: 頁回收
ru_majflt: 頁失效
ru_nsignals: 收到的信號
ru_nvcsw: 主動上下文切換
ru_nivcsw: 被動上下文切換
ru_nswap: 交換區
ru_utime.tv_usec: 用戶態時間 (microseconds)
ru_utime.tv_sec: 用戶態時間(seconds)
ru_stime.tv_usec: 系統內核時間 (microseconds)
ru_stime.tv_sec: 系統內核時間(seconds)
*/
//do something
sleep(1);
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>
#include <time.h>
#include <unistd.h>
int main(void)
{
while(1)
{
struct rusage ru;
memset(&ru, 0, sizeof(struct rusage));
getrusage(RUSAGE_SELF, &ru);
printf("ou/inblock:%ld,%ld,snd/rcvmsg:%ld,%ld,max/ix/idrss:%ld,%ld,%ld,min/majflt:%ld,%ld,signal:%ld,nv/nivcsw:%ld,%ld,swap:%ld,utime:%lu,%lu,stime:%lu,%lu\r\n",
ru.ru_oublock, ru.ru_inblock,
ru.ru_msgsnd, ru.ru_msgrcv,
ru.ru_maxrss, ru.ru_ixrss, ru.ru_idrss,
ru.ru_minflt, ru.ru_majflt,
ru.ru_nsignals,
ru.ru_nvcsw, ru.ru_nivcsw,
ru.ru_nswap,
ru.ru_utime.tv_usec, ru.ru_utime.tv_sec,
ru.ru_stime.tv_usec, ru.ru_stime.tv_sec);
/*
ru_oublock: 塊輸出操作
ru_inblock: 塊輸入操作
ru_msgsnd: 發送的message
ru_msgrcv: 收到的message
ru_maxrss: 最大駐留集大小
ru_ixrss: 全部共享內存大小
ru_idrss:全部非共享內存大小
ru_minflt: 頁回收
ru_majflt: 頁失效
ru_nsignals: 收到的信號
ru_nvcsw: 主動上下文切換
ru_nivcsw: 被動上下文切換
ru_nswap: 交換區
ru_utime.tv_usec: 用戶態時間 (microseconds)
ru_utime.tv_sec: 用戶態時間(seconds)
ru_stime.tv_usec: 系統內核時間 (microseconds)
ru_stime.tv_sec: 系統內核時間(seconds)
*/
//do something
sleep(1);
}
return 0;
}