测试用指定块大小读取文件时间的代码
2012-04-13 09:50
411 查看
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/xattr.h>
#include <sys/stat.h>
#include <pthread.h>
#include <fcntl.h>
#include <utime.h>
#include <sys/time.h>
#include <errno.h>
#include <dirent.h>
#include<sys/time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/xattr.h>
#include <sys/stat.h>
#include <pthread.h>
#include <fcntl.h>
#include <utime.h>
#include <sys/time.h>
#include <errno.h>
#include <dirent.h>
#include<sys/time.h>
int main(int argv,char*argc[])
{
int i=512;//指定读取的块的大小
int j=i*1024;
char databuf[j];
struct timeval t_start,t_end;
long const_timeopen=0;
long const_timeread=0;
//get opent sart time
gettimeofday(&t_start,NULL);
printf("start open time :%ld us\n",t_start.tv_usec);
int file=open(argc[1],O_RDONLY);//输入要去的文件名
if (file == -1) {
close (file);
printf("error\n");}
while(0<read(file,databuf,32*1024)){
// printf("databuf=%s\n",databuf);
}
close(file);
//get end time
gettimeofday(&t_end,NULL);
printf("end open time:%ld us\n",t_end.tv_usec);
//const open time
const_timeopen=t_end.tv_usec-t_start.tv_usec;
printf("const open time :%ld us\n",const_timeopen);
printf("over!\n");
}
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/xattr.h>
#include <sys/stat.h>
#include <pthread.h>
#include <fcntl.h>
#include <utime.h>
#include <sys/time.h>
#include <errno.h>
#include <dirent.h>
#include<sys/time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/xattr.h>
#include <sys/stat.h>
#include <pthread.h>
#include <fcntl.h>
#include <utime.h>
#include <sys/time.h>
#include <errno.h>
#include <dirent.h>
#include<sys/time.h>
int main(int argv,char*argc[])
{
int i=512;//指定读取的块的大小
int j=i*1024;
char databuf[j];
struct timeval t_start,t_end;
long const_timeopen=0;
long const_timeread=0;
//get opent sart time
gettimeofday(&t_start,NULL);
printf("start open time :%ld us\n",t_start.tv_usec);
int file=open(argc[1],O_RDONLY);//输入要去的文件名
if (file == -1) {
close (file);
printf("error\n");}
while(0<read(file,databuf,32*1024)){
// printf("databuf=%s\n",databuf);
}
close(file);
//get end time
gettimeofday(&t_end,NULL);
printf("end open time:%ld us\n",t_end.tv_usec);
//const open time
const_timeopen=t_end.tv_usec-t_start.tv_usec;
printf("const open time :%ld us\n",const_timeopen);
printf("over!\n");
}
相关文章推荐
- java读取文件并获得文件编码,转换为指定编码的工具类代码
- JXL读取Excel文件测试代码
- delphi 同盘移动文件所用时间测试(文件大小约6,083,545,088 字节)
- .net core 读取本地指定目录下的文件的实例代码
- Elastic测试笔记:logstash读取redis,指定时间字段
- Shell脚本创建指定大小文件的测试数据
- 测试python awk sed 读取文件指定位置时的性能
- php使用curl下载指定大小的文件实例代码
- 【实战代码】PHP实现读取一个1G的文件大小
- 生成指定大小文件供测试
- 测试python awk sed 读取文件指定位置时的性能
- python 生成器按指定大小读取文件
- 测试专用,跨平台批量生成指定大小及个数的文件(非稀疏文件)
- 2.1-2.4.文件读取时间测试
- 读取控制卡文件、文件时间、文件大小
- Linux下按照时间和大小生成新文件的程序流程及其C代码实现
- java:24G文件写入所要时间23.9分,读取只有67秒(1G内存测试)
- java 代码读取指定文件
- java读取文件并获得文件编码,转换为指定编码的工具类代码
- 批处理 显示指定文件夹下文件的大小和时间