|
本帖最后由 20011010wo 于 2016-11-13 11:19 编辑
输入驱动器盘符和测试大小(单位MB)即可(分号间隔),
只是为了连续写入后看磁盘温度的,读取,数据校验啥都没
DiskCheck.exe
(140 KB, 下载次数: 839)
- #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[MAX_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[block_size];
- srand((unsigned int)time(0));
- for (unsigned long num = 0L;num < block_size;num++)
- {
- data[num] = (byte)(rand() % (2 ^ ((sizeof(byte) * 8))));
- }
- full_path[0] = 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;
- }
复制代码
|
|