易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

Linux命令:modinfo显示kernel模块信息

modinfo(module infomation)
功能说明:显示kernel模块的信息。
语  法:modinfo [-adhpV][模块文件]
补充说明:modinfo会显示kernel模块的对象文件,以显示该模块的相关信息。
参  数:
  -a或--author  显示模块开发人员。 
  -d或--description  显示模块的说明。& ......

[转] linux下创建oracle用户表空间

转自: http://blog.csdn.net/kongqz/archive/2009/05/15/4184415.aspx
就是在已有的数据库实例上创建一个新的帐号,访问一些新的表
 操作步骤如下:
 1、登录linux,以oracle用户登录(如果是root用户登录的,登录后用 su - oracle命令切换成oracle用户)
 2、以sysdba方式来打开sqlplus,命令如下: s ......

linux压缩和解压缩命令大全


linux压缩和解压缩命令大全

        .tar
  解包:tar zxvf FileName.tar
  打包:tar czvf FileName.tar DirName
  ---------------------------------------------
  .gz
  解压1:gunzip FileName.gz
  解压2:gzip -d FileName.gz
  压缩:gzip File ......

Linux ubuntu设置root密码

Ubuntu 7.10
在安装时,没有设置root密码,所以这就必须在安装完成后设置 命令如下:
$ sudo passwd root
输入你希望的root用户的密码
其它命令:
一、安装Grub
$ grub
$ find /boot/grub/stage1
(hd0,*)
$ root (hd0,*)
$ setup (hd0,*)
$ quit
$ sudo dd if=/de ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号