磁盘写入测试
本帖最后由 20011010wo 于 2016-11-13 11:19 编辑输入驱动器盘符和测试大小(单位MB)即可(分号间隔),
只是为了连续写入后看磁盘温度的,读取,数据校验啥都没
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <wchar.h>
#include <io.h>
#include <fcntl.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <share.h>
#include <windows.h>
#include <time.h>
class timer
{
public:
timer()
{
QueryPerformanceFrequency(&large_interger);
}
~timer() = default;
void start()
{
QueryPerformanceCounter(&tickCount);
}
void stop()
{
QueryPerformanceCounter(&tickCountLate);
}
double count()
{
return (double)((tickCountLate.QuadPart - tickCount.QuadPart) * 1000.0000 / large_interger.QuadPart);
}
private:
LARGE_INTEGER tickCount;
LARGE_INTEGER tickCountLate;
LARGE_INTEGER large_interger;
};
int wmain()
{
for (;;)
{
int fh = 0;
wchar_t tg = 0, unit = 0, full_path = L" :\\diskcheck.buffer";
unsigned long size = 0;
unsigned block_size = 1024 * 1024;
double used_time = 0;
wprintf(L"Input 'Target;Size'\n");
wscanf(L"%wc;%lu", &tg, &size);
byte *data = new byte;
srand((unsigned int)time(0));
for (unsigned long num = 0L;num < block_size;num++)
{
data = (byte)(rand() % (2 ^ ((sizeof(byte) * 8))));
}
full_path = tg;
if (_wsopen_s(&fh, full_path, _O_CREAT | _O_TEMPORARY | _O_BINARY | _O_WRONLY, _SH_DENYNO, _S_IREAD | _S_IWRITE) != 0)
{
wprintf_s(L"ERROR!\n");
break;
}
_lseek(fh, 0L, SEEK_SET);
timer timer_obj;
timer_obj.start();
for (unsigned long count = 0;count < size;count++)
{
_write(fh, data, block_size);
_commit(fh);
}
timer_obj.stop();
used_time = timer_obj.count();
_close(fh);
DeleteFileW(full_path);
delete[] data;
wprintf_s(L"Used Time:%lf ms,Write:%lu MB,Speed:%lf MB/s\n", used_time, size, ((double)size) / ((double)used_time / 1000));
_wsystem(L"pause");
}
return 0;
}
源码呢 试一下,看看 可怜的LZ,软件都没人用。 nkc3g4 发表于 2016-12-11 13:27
可怜的LZ,软件都没人用。
明明是自用的,检测到cf写了600m数据就崩溃
页:
[1]