萝卜头IT论坛

搜索
查看: 4415|回复: 4
收起左侧

磁盘写入测试

[复制链接]
发表于 2016-11-13 08:57:20 | 显示全部楼层 |阅读模式
本帖最后由 20011010wo 于 2016-11-13 11:19 编辑

输入驱动器盘符和测试大小(单位MB)即可(分号间隔),
-4b6c46b6e4adcb89.jpg
只是为了连续写入后看磁盘温度的,读取,数据校验啥都没
DiskCheck.exe (140 KB, 下载次数: 724)
  1. #define _CRT_SECURE_NO_WARNINGS 1

  2. #include <stdio.h>
  3. #include <wchar.h>
  4. #include <io.h>
  5. #include <fcntl.h>
  6. #include <sys\types.h>
  7. #include <sys\stat.h>
  8. #include <share.h>
  9. #include <windows.h>
  10. #include <time.h>

  11. class timer
  12. {
  13. public:
  14.         timer()
  15.         {
  16.                 QueryPerformanceFrequency(&large_interger);
  17.         }
  18.         ~timer() = default;
  19.         void start()
  20.         {
  21.                 QueryPerformanceCounter(&tickCount);
  22.         }
  23.         void stop()
  24.         {
  25.                 QueryPerformanceCounter(&tickCountLate);
  26.         }
  27.         double count()
  28.         {
  29.                 return (double)((tickCountLate.QuadPart - tickCount.QuadPart) * 1000.0000 / large_interger.QuadPart);
  30.         }
  31. private:
  32.         LARGE_INTEGER tickCount;
  33.         LARGE_INTEGER tickCountLate;
  34.         LARGE_INTEGER large_interger;
  35. };



  36. int wmain()
  37. {
  38.         for (;;)
  39.         {
  40.                 int fh = 0;
  41.                 wchar_t tg = 0, unit = 0, full_path[MAX_PATH] = L" :\\diskcheck.buffer";
  42.                 unsigned long size = 0;
  43.                 unsigned block_size = 1024 * 1024;
  44.                 double used_time = 0;
  45.                 wprintf(L"Input 'Target;Size'\n");
  46.                 wscanf(L"%wc;%lu", &tg, &size);

  47.                 byte *data = new byte[block_size];
  48.                 srand((unsigned int)time(0));
  49.                 for (unsigned long num = 0L;num < block_size;num++)
  50.                 {
  51.                         data[num] = (byte)(rand() % (2 ^ ((sizeof(byte) * 8))));
  52.                 }
  53.                 full_path[0] = tg;
  54.                 if (_wsopen_s(&fh, full_path, _O_CREAT | _O_TEMPORARY | _O_BINARY | _O_WRONLY, _SH_DENYNO, _S_IREAD | _S_IWRITE) != 0)
  55.                 {
  56.                         wprintf_s(L"ERROR!\n");
  57.                         break;
  58.                 }
  59.                 _lseek(fh, 0L, SEEK_SET);
  60.                 timer timer_obj;
  61.                 timer_obj.start();
  62.                 for (unsigned long count = 0;count < size;count++)
  63.                 {
  64.                         _write(fh, data, block_size);
  65.                         _commit(fh);
  66.                 }
  67.                 timer_obj.stop();
  68.                 used_time = timer_obj.count();
  69.                 _close(fh);
  70.                 DeleteFileW(full_path);
  71.                 delete[] data;
  72.                 wprintf_s(L"Used Time:%lf ms,Write:%lu MB,Speed:%lf MB/s\n", used_time, size, ((double)size) / ((double)used_time / 1000));
  73.                 _wsystem(L"pause");
  74.         }
  75.         return 0;
  76. }
复制代码



回复

使用道具 举报

发表于 2016-11-13 10:16:21 | 显示全部楼层
源码呢
回复

使用道具 举报

发表于 2016-11-23 15:05:13 | 显示全部楼层
试一下,看看
回复

使用道具 举报

发表于 2016-12-11 13:27:33 | 显示全部楼层
可怜的LZ,软件都没人用。
回复

使用道具 举报

 楼主| 发表于 2016-12-11 15:23:48 | 显示全部楼层
nkc3g4 发表于 2016-12-11 13:27
可怜的LZ,软件都没人用。

明明是自用的,检测到cf写了600m数据就崩溃
回复

使用道具 举报

联系我们(Contact)|手机版|萝卜头IT论坛 ( 苏ICP备15050961号-1 )

GMT+8, 2024-4-19 10:57 , Processed in 0.109419 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表