#include "stdio.h"
#include "sys/times.h"
#include "time.h"
#include "unistd.h"
static void do_cmd(char *);
int main(int argc,char *argv[])
{
if(argc == 1)
{
printf("Usage: %s cmd\n",argv[0]);
exit(1);
}
struct tms tmsstart,tmsend;
clock_t start,end;
start=times(&tmsstart);
system(argv[1]);
end=times(&tmsend);
clock_t real=end-start;
// system base start
static long base= 0;
base=sysconf( _SC_CLK_TCK );
// system base end
printf("real: %7.2f\n",real/(double) base);
printf("user: %7.2f\n",(tmsend.tms_utime-tmsstart.tms_utime)/(double) base);
printf("cpu: %7.2f\n",(tmsend.tms_stime-tmsstart.tms_stime)/(double) base);
}
C-sys/time
原创
©著作权归作者所有:来自51CTO博客作者bio_tt的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:C-pipe
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
详解Python中sys模块的功能与应用
本文将介绍sys模块的一些常用函数和方法,并通过实际的代码实例来解析它们的用法。
生成器 Python 递归 sys模块 函数 -
聊聊TCP中的TIME_WAIT
TIME_WAIT 的产生、作用以及优化
TIME_WAIT -
关于time.h
一直对时间函数有点兴趣,今天打开time.h看
显示格式 字符串 时间函数 for循环 unix -
【c】time.h
表示时间的三种类型日历时间:从一个时间点到现在的秒数,用time_t表示始终滴答时间:从进程启动到现在时钟的滴答数(每秒一
#include ios 转换函数 -
atltime.h和time.h函数冲突
不然可能导致函数库冲突。使用atltime库: #incl...
2d #include 函数库 -
逆向 time.h 函数库 time、gmtime 函数
0x01 time 函数函数原型:time_...
函数返回 2d #include