m****t 发帖数: 145 | 1 当计算一个program的CPU运行时间时,在Java中可在program开始和结束时
分别调用System.currentTimeMillis()并求得两者之差,为CPU时间.
类似地,在C/C++中可用time.h中的time函数来实现这一点.
我的问题是: 当server上有多个进程共享CPU, 用上面方法求得的CPU时间
是仅仅包括我的program在CPU自己运行的时间,还是也包括从我的program
运行开始到结束期间所有其他进程占据CPU的时间?
我的paper明天就要due,我现在正在统计实验数据.望哪位大下能迅速解答
我的问题,不胜感激!!!!!! | l*l 发帖数: 225 | 2 The define of 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 */
};
And the stime is the cpu time of you process. It didn't count in other proce
sses.
You can check it by sample program with sleep function.
read < advance programming in UNIX enviorment
【在 m****t 的大作中提到】 : 当计算一个program的CPU运行时间时,在Java中可在program开始和结束时 : 分别调用System.currentTimeMillis()并求得两者之差,为CPU时间. : 类似地,在C/C++中可用time.h中的time函数来实现这一点. : 我的问题是: 当server上有多个进程共享CPU, 用上面方法求得的CPU时间 : 是仅仅包括我的program在CPU自己运行的时间,还是也包括从我的program : 运行开始到结束期间所有其他进程占据CPU的时间? : 我的paper明天就要due,我现在正在统计实验数据.望哪位大下能迅速解答 : 我的问题,不胜感激!!!!!!
| p**h 发帖数: 99 | 3 which header file is it in? and what functions to use with this 'tms'?
【在 l*l 的大作中提到】 : The define of 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 */ : }; : And the stime is the cpu time of you process. It didn't count in other proce : sses. : You can check it by sample program with sleep function.
|
|