Linux C | 时间测量
来源:互联网 发布:网络安全工程师学什么 编辑:程序博客网 时间:2024/04/28 18:54
关键函数
int gettimeofday(struct timeval *tv,struct timezone *tz);
gettimeofday 将时间保存在结构 tv 之中.tz 一般我们使用 NULL 来代替.
long tv_sec; /* 秒数 */
long tv_usec; /* 微秒数 */
};
这个程序输出函数的执行时间,我们可以使用这个来进行系统性能的测试,或者是函数算法的效率分析.
在我机器上的一个输出结果是: Used Time:0.053519
#include <sys/time.h>#include <stdio.h>#include <math.h>void function(){unsigned int i,j;double y;for(i=0;i<1000;i++)for(j=0;j<1000;j++)y=sin((double)i);}main(){struct timeval tpstart,tpend;float timeuse;gettimeofday(&tpstart,NULL);function();gettimeofday(&tpend,NULL);timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+tpend.tv_usec-tpstart.tv_usec;timeuse/=1000000;printf("Used Time:%f\n",timeuse);exit(0);}
- Linux C | 时间测量
- 如何测量C#代码的运行时间
- c/c++测量程序运行时间
- 如何测量C#代码的运行时间
- Linux下高精度的时间测量
- linux测量时间的各种方法比较
- Linux下测量程序运行时间
- linux测量时间的各种方法比较
- Linux内核延时和时间测量函数
- 【时间测量】代码运行时间的测量方法【linux/window】
- C语言中的测量程序运行时间的函数
- C/C++测量时间的几种方式
- opencv(C++)扫描图像,查找表和时间测量
- Linux测量kernel子模块加载时间的方法
- Linux测量kernel子模块加载时间的方法
- Linux测量kernel子模块加载时间的方法
- Linux测量kernel子模块加载时间的方法
- Linux测量kernel子模块加载时间的方法
- 运用dtree组件动态生成带复选框的目录树
- POJ3657.Haybale Guessing
- ubuntu 11.04 下载和编译Android代码
- tcp死连接问题
- 关于CSDN, cnblog, iteye和51cto四个博客网站的比较与分析
- Linux C | 时间测量
- 调度系统
- Cisco ASA在线配置手册
- 好久没来了。
- TCP/IP协议笔记
- 大规模tcp并连接支持的思路
- More Effective C++摘录
- 原来这个叫做广搜啊。。。
- 多线程编程技术