作者tttp86 (鄉民就是我)
看板KMU_CIA
標題[心得] 簡單的硬碟測速程式~~~
時間Fri Apr 13 20:05:39 2007
因為很好奇硬碟寫入速度到底怎樣,
所以寫了有趣的小程式。
大家可以用dev-c++編譯後,
就可以顯示硬碟的寫入速度如何喔~~~~
=============================================
//#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <time.h>
#include <limits>
//#include <math.h>
using namespace std;
int main(void)
{
clock_t start, finish;
double duration;
unsigned int j = numeric_limits<unsigned int>::max();
//unsigned int j = pow(2,(sizeof(j)*8))-1; //理論上啦,4294967295;
int MB_num = 100;
ofstream File_obj("TestData" , ios_base::out | ios_base::binary);
//計時開始
start = clock();
for ( unsigned long i = 0; i < (1024*(1024/sizeof(j))*MB_num); ++i)
File_obj.write( reinterpret_cast<char*>(&j), sizeof(j));
//計時結束
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
File_obj.close();
double Rate = MB_num/duration;
cout << "測試時間:" << duration << "秒" << endl;
cout << "共寫入" << MB_num << "MB" << endl;
cout << "磁碟寫入速率為" << Rate << "MB/秒";
return 0;
}
=============================================
歡迎大家試試看,然後告訴我大家的速度怎樣喔~~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 221.169.236.105
→ apharmy:前4句話都看得懂..就是這句 大家可以用dev-c++編譯後, 04/13 22:19
→ apharmy:不知道什麼意思.... 04/13 22:19