2010-09-25 60 views

回答

1

使用的时代呼唤 - 根据手册页:

名称 时间 - 获取进程倍

概要 的#include <SYS/times.h>

clock_t times(struct tms *buf); 

描述 times()将当前进程时间存储在buf指向的struct tms中。结构 tms定义如下:

 struct tms { 
      clock_t tms_utime; /* user time */ 
      clock_t tms_stime; /* system time */ 
      clock_t tms_cutime; /* user time of children */ 
      clock_t tms_cstime; /* system time of children */ 
     }; 

    The tms_utime field contains the CPU time spent executing instructions of the calling 
    process. The tms_stime field contains the CPU time spent in the system while executing 
    tasks on behalf of the calling process. The tms_cutime field contains the sum of the 
    tms_utime and tms_cutime values for all waited-for terminated children. The tms_cstime 
    field contains the sum of the tms_stime and tms_cstime values for all waited-for terminated 
    children. 
0

我会用GetProcessTimes函数,如果你在Windows环境下编程。该函数返回进程使用的内核和用户时间。在需要开始时间然后进行最终测试之前,您需要调用它。

看看它是否超过挂钟时间的50%。

时间为FILETIME格式。此格式旨在支持程序支持不同的整数格式,因此请选择正确的格式。

+0

不幸的是我在linux上 – 2010-09-25 03:22:55

相关问题