avatar
关于CPU时间急问!# Unix - 噫吁兮,危乎高哉
m*t
1
当计算一个program的CPU运行时间时,在Java中可在program开始和结束时
分别调用System.currentTimeMillis()并求得两者之差,为CPU时间.
类似地,在C/C++中可用time.h中的time函数来实现这一点.
我的问题是: 当server上有多个进程共享CPU, 用上面方法求得的CPU时间
是仅仅包括我的program在CPU自己运行的时间,还是也包括从我的program
运行开始到结束期间所有其他进程占据CPU的时间?
我的paper明天就要due,我现在正在统计实验数据.望哪位大下能迅速解答
我的问题,不胜感激!!!!!!
avatar
l*l
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,我现在正在统计实验数据.望哪位大下能迅速解答
: 我的问题,不胜感激!!!!!!

avatar
p*h
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.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。