linux下ssd电子盘速度检测
2015-05-07 15:40
330 查看
代码:
写测试运行结果:
# ./test
# gcc ssd_test.c -o test -lpthread
# ./test
SSD Speed test begin!
SSD4 test over!
SSD0 test over!
SSD6 test over!
SSD1 test over!
SSD5 test over!
SSD7 test over!
SSD2 test over!
SSD3 test over!
ssd write speed:1563.73594MB/S(1.30968sec)
SSD Speed test over!
读测试运行结果:
# ./testSSD Speed test begin!
SSD1 test over!
SSD7 test over!
SSD3 test over!
SSD2 test over!
SSD4 test over!
SSD5 test over!
SSD6 test over!
SSD0 test over!
ssd read speed:2315.16042MB/S(0.34623sec)
SSD Speed test over!
#include<stdio.h> #include<sys/time.h> #include <fcntl.h> #include <pthread.h> unsigned char pbuffer[1024*1024*8];//共用缓冲 void testssd1(int *ch )//写测试 { int i=0; int fd; if(*ch==0) fd = open("/ssd1/test.dat", O_RDWR|O_CREAT); if(*ch==1) fd = open("/ssd2/test.dat", O_RDWR|O_CREAT); if(*ch==2) fd = open("/ssd3/test.dat", O_RDWR|O_CREAT); if(*ch==3) fd = open("/ssd4/test.dat", O_RDWR|O_CREAT); if(*ch==4) fd = open("/ssd5/test.dat", O_RDWR|O_CREAT); if(*ch==5) fd = open("/ssd6/test.dat", O_RDWR|O_CREAT); if(*ch==6) fd = open("/ssd7/test.dat", O_RDWR|O_CREAT); if(*ch==7) fd = open("/ssd8/test.dat", O_RDWR|O_CREAT); if(fd<0) { printf("%d open error!\n",*ch); return ; } for(i=0;i<32;i++) write(fd,pbuffer,1024*1024*8);//每次8M,共计256MB close(fd); printf("SSD%d test over!\n",*ch); return ; } void testssd2(int *ch )//读测试 { int i=0; int fd; if(*ch==0) fd = open("/ssd1/test.dat", O_RDWR|O_CREAT); if(*ch==1) fd = open("/ssd2/test.dat", O_RDWR|O_CREAT); if(*ch==2) fd = open("/ssd3/test.dat", O_RDWR|O_CREAT); if(*ch==3) fd = open("/ssd4/test.dat", O_RDWR|O_CREAT); if(*ch==4) fd = open("/ssd5/test.dat", O_RDWR|O_CREAT); if(*ch==5) fd = open("/ssd6/test.dat", O_RDWR|O_CREAT); if(*ch==6) fd = open("/ssd7/test.dat", O_RDWR|O_CREAT); if(*ch==7) fd = open("/ssd8/test.dat", O_RDWR|O_CREAT); if(fd<0) { printf("%d open error!\n",*ch); return ; } for(i=0;i<32;i++) read(fd,pbuffer,1024*1024*8); close(fd); printf("SSD%d test over!\n",*ch); return ; } int main() { printf("this is SSD Speed test begin!\n\n"); pthread_t _id[8]; int ret,i,ch[8]; struct timeval start; struct timeval end; float speed; for(i=0;i<1024*1024*8;i++)//初始化缓冲区 pbuffer[i] = i&0xff; gettimeofday(&start,NULL);//开始计时------------ for(i=0;i<8;i++) { ch[i] = i;//启动8个线程 ret=pthread_create(_id+i,NULL,(void *)testssd1,ch+i); if(ret!=0) { printf("Create pthread error!\n"); return -1; } } pthread_join(_id[0],NULL); //等待各自到线程结束 pthread_join(_id[1],NULL); pthread_join(_id[2],NULL); pthread_join(_id[3],NULL); pthread_join(_id[4],NULL); pthread_join(_id[5],NULL); pthread_join(_id[6],NULL); pthread_join(_id[7],NULL); gettimeofday(&end, NULL);//停止计时------------- speed = 1.0*(end.tv_sec-start.tv_sec)+(end.tv_usec-start.tv_usec)/1000000.0;//时间 printf("ssd write speed:%6.5fMB/S(%6.5fsec)\n",256.0*8/speed,speed); //速度 printf("this is SSD Speed test over!\n\n"); return 0; }
写测试运行结果:
# ./test
# gcc ssd_test.c -o test -lpthread
# ./test
SSD Speed test begin!
SSD4 test over!
SSD0 test over!
SSD6 test over!
SSD1 test over!
SSD5 test over!
SSD7 test over!
SSD2 test over!
SSD3 test over!
ssd write speed:1563.73594MB/S(1.30968sec)
SSD Speed test over!
读测试运行结果:
# ./testSSD Speed test begin!
SSD1 test over!
SSD7 test over!
SSD3 test over!
SSD2 test over!
SSD4 test over!
SSD5 test over!
SSD6 test over!
SSD0 test over!
ssd read speed:2315.16042MB/S(0.34623sec)
SSD Speed test over!
相关文章推荐
- linux下ssd电子盘速度检测 分类: arm-linux-Ubuntu 2015-05-07 15:40 307人阅读 评论(0) 收藏
- linux下ssd电子盘速度检测
- linux下ssd电子盘速度检测
- 在 Linux 上检测 IDE/SATA SSD 硬盘的传输速度
- Linux下检测DVD刻录机的设备名及写入速度的几种方法
- Linux终端:speedtest_cli检测你的实时带宽速度
- Linux终端:speedtest_cli检测你的实时带宽速度
- 在 Linux 上检测 IDE/SATA SSD 硬盘的传输速度 | Linux 中国
- Linux系统中使用 DD 命令测试 USB 和 SSD 硬盘的读写速度
- Linux系统中使用 DD 命令测试 USB 和 SSD 硬盘的读写速度
- Linux 磁盘I/O读写速度检测
- 如何使用Linux命令行检测DVD刻录机的名字和读写速度
- Linux检测硬盘读取速度
- Linux系统中使用 DD 命令测试 USB 和 SSD 硬盘的读写速度
- Linux有问必答:如何使用Linux命令行检测DVD刻录机的名字和读写速度
- Linux 编译SSD Caffe目标检测代码
- linux下防入侵检测实现
- Linux 常用检测命令
- linux 检测网线拨出
- [linux]警告:检测到时钟错误。您的创建可能是不完整的。