- 论坛徽章:
- 2
|
int main(int argc, char **argv)
{
clock_t stime, etime;
struct tms sbuf, ebuf;
int status;
static long clktck = 0;
if ((stime = times(&sbuf)) == -1)
err_sys("times error");
if ((status = system("sleep 1; pwd")) < 0)
err_sys("system error");
if ((etime = times(&ebuf)) == -1)
err_sys("times error");
clktck = sysconf(_SC_CLK_TCK);
printf("rtime: %7.2f\n", (etime-stime)/(double)clktck);
printf("utime: %7.2f\n", (ebuf.tms_utime - sbuf.tms_utime)/(double)clktck);
printf("stime: %7.2f\n", (ebuf.tms_stime - sbuf.tms_stime)/(double)clktck);
printf("cutime: %7.2f\n", (ebuf.tms_cutime - sbuf.tms_cutime)/(double)clktck);
printf("cstime: %7.2f\n", (ebuf.tms_cstime - sbuf.tms_cstime)/(double)clktck);
exit(0);
}
平安夜一点不平安,呵呵,为啥只有rtime是对的,stime和utime都是0呢???
|
|