2010-09-25 56 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

相關問題