易截截图软件、单文件、免安装、纯绿色、仅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下创建oracle用户表空间

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

/etc/hosts file in linux configure manual

Name
hosts - The static table lookup for host names
Synopsis
/etc/hosts
Description
This manual page describes the format of the /etc/hosts
file. This file is a simple text file that
associates IP addresses with hostnames, one line per IP address. For
each host a single line should be presen ......

linux常用命令

shell语法(五项)
1.命令格式
2.通配符
3.重定向
4.管道
5.shell中的引用
6.自动补齐命令行
系统管理维护
ls
pwd
cd
date
passwd
su
clear
man
who
w
uname
uptime
last
dmesg
free
ps
top
文件管理编辑
mkdir
more
cat
diff
grep
rm
touch
ln
file
cp
find
split
mv
压缩解压
zi ......

linux的学习规划

   按以下步骤来,先写这么多来提醒下自己:
       1.熟悉linux的基本环境,熟悉linux的基本命令.
       2.熟悉linux的交叉编译环境的的配置.
       3.复习基本的C语言知识.
     &nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号