本版
查看: 7843|回复: 4

磁盘写入测试

[复制链接]

[Lv.7]特大萝卜

楼主(1#)
发表于 2016-11-13 08:57:20 | 只看该作者 |只看大图 |倒序浏览 |阅读模式
本帖最后由 20011010wo 于 2016-11-13 11:19 编辑

输入驱动器盘符和测试大小(单位MB)即可(分号间隔),

只是为了连续写入后看磁盘温度的,读取,数据校验啥都没
DiskCheck.exe
  1. #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;
    }



回复

支持 | 反对  0 支持 / 0 反对 评分 举报

Super Moderator

沙发(2#)
发表于 2016-11-13 10:16:21 | 只看该作者
源码呢
板凳(3#)
发表于 2016-11-23 15:05:13 | 只看该作者
试一下,看看

Super Moderator

地板(4#)
发表于 2016-12-11 13:27:33 | 只看该作者
可怜的LZ,软件都没人用。

[Lv.7]特大萝卜

5#
 楼主| 发表于 2016-12-11 15:23:48 | 只看该作者
nkc3g4 发表于 2016-12-11 13:27
可怜的LZ,软件都没人用。

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

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

GMT+8, 2026-10-19 05:25 , Processed in 0.07 second(s), 20 queries , Gzip On.

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