Linux获取毫秒级时间
Linux获取毫秒级时间
Moakap
在软件设计中经常会用到关于时间的处理,用来计算语句、函数的执行时间,这时就需要精确到毫秒甚至是微妙的时间。
int gettimeofday(struct
timeval *tv, struct timezone *tz);
int settimeofday(const
struct timeval *tv , const struct timezone *tz);
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /*
microseconds */
};
struct timezone {
int tz_minuteswest; /* minutes
west of Greenwich
*/
int
tz_dsttime; /* type of DST
correction */
};
下面是个简单的例子,用来统计程序的执行时间:
…
struct timeval
t_start,t_end;
long cost_time = 0;
//get start
time
gettimeofday(&t_start,
NULL);
printf("Start
time: %ld us", t_start.tv_usec);
//some
operation
…
//get end time
gettimeofday(&t_end,
NULL);
printf("End
time: %ld us", t_end.tv_usec);
//calculate
time slot
cost_time =
t_end.tv_usec - t_start.tv_usec;
printf("Cost
time: %ld us", cost_time);
…
输出:
Start time:
438061 us
End time:
459867 us
Cost time:
21806 us
相关文档:
本函数的分析很难具体,因为涉及了很多arm的处理器型号和每个型号对应的cache和write buffer的工作方式,这片文章只是做简单的记录,方便以后了解更深后回来再来完善这个函数。
这个函数的调用过程如:start_kernel()->setup_arch()->paging_init()->memtable_init( ......
modinfo(module infomation)
功能说明:显示kernel模块的信息。
语 法:modinfo [-adhpV][模块文件]
补充说明:modinfo会显示kernel模块的对象文件,以显示该模块的相关信息。
参 数:
-a或--author 显示模块开发人员。
-d或--description 显示模块的说明。& ......
在linux下安装oracle是件繁琐的事情。具体来讲分为一下几大步:
1.修改系统版本
vi /etc/redhat-release
注释掉第一行,添加一行:redhat-4
2.安装软件包
rpm -Uvh setarch-2*
rpm -Uvh make-3*
rpm -Uvh glibc-2*
rpm -Uvh libaio-0*
rpm -Uvh compat-libstdc++-33-3*
rpm -Uvh compat-gcc-34-3*
rpm -Uvh comp ......