001.linux下clock()检测程序运行时间
2015-11-16 17:11
417 查看
#include <stdio.h> #include <time.h> int main() { int i; int k; clock_t start,end; //clock_t类型实际上为long int类型(4字节) printf("%d\n",sizeof(long int)); start = clock(); printf("start:%d\n",start); for(i=0; i<10000000; i++) ; end = clock(); printf("end:%d\n",end); printf("%.3fs\n",(double)(end-start)/CLOCKS_PER_SEC); //linux下CLOCKS_PER_SEC=1000000 }
运行结果:
4
start:0
end:20000
0.020s
相关文章推荐
- linux 无法使用pstree命令
- linux查询cpu核心数
- Unix学习笔记-------目录遍历实例----Linux下判断是否是一个目录还是一个文件的方法
- centos 6.4 升级 python 安装pip
- svnserver 服务怎么在centos6.4上部署
- Linux C 时间服务器
- centos的安装以及yum源的配置以及视频flash的设置
- 基于清单的启动器的实现
- CentOS 7下关于systemd的一些唠叨话二:systemd服务脚本的编写
- CentOs常见命令问题集合
- ubuntu14.4安装linux问题
- 我学习嵌入式linux开发入门过程(五)
- CentOS 7下关于systemd的一些唠叨话一:systemd的特点和使用
- linux服务器(一)之时间与帮助详解
- linux find命令
- linux 修改系统时间
- centos7的安装及配置
- Linux进程间通信(IPC)编程实践(五)消息队列实现回射客户/服务器
- Linux设置服务自启动的三种方式
- Linux Svn 安装过程及配置