Alternate e697dbe9c5997e35395fe158628dd8c5209481da
for Visual Studio 2022 and Windows 11.
読み取り中…
検索中…
一致する文字列を見つけられません
FilePerformanceCheck.cpp
[詳解]
1
5
6#include "pch.h"
8
9using namespace PerfCheck;
10
12 :PerformanceCheck (console)
13{
14 _maxFileSize = -1;
15}
16
18{
19}
20
22{
23 _maxFileSize = 16 * 1000;
24 this->Core ((int)pow (2, 0)); // 1
25 this->Core ((int)pow (2, 1)); // 2
26 this->Core ((int)pow (2, 2)); // 4
27 this->Core ((int)pow (2, 3)); // 8
28 this->Core ((int)pow (2, 4)); // 16
29
30 _maxFileSize = 512 * 100;
31 this->Core ((int)pow (2, 5)); // 32
32 this->Core ((int)pow (2, 6)); // 64
33 this->Core ((int)pow (2, 7)); // 128
34 this->Core ((int)pow (2, 8)); // 256
35 this->Core ((int)pow (2, 9)); // 512
36
37 _maxFileSize = 16384 * 100;
38 this->Core ((int)pow (2, 10)); // 1,024
39 this->Core ((int)pow (2, 11)); // 2,048
40 this->Core ((int)pow (2, 12)); // 4,096
41 this->Core ((int)pow (2, 13)); // 8,192
42 this->Core ((int)pow (2, 14)); // 16,384
43
44 _maxFileSize = 1048576 * 100;
45 this->Core ((int)pow (2, 15)); // 32,768
46 this->Core ((int)pow (2, 16)); // 65,536
47 this->Core ((int)pow (2, 17)); // 131,072
48 this->Core ((int)pow (2, 18)); // 262,144
49 this->Core ((int)pow (2, 19)); // 524.288
50 this->Core ((int)pow (2, 20)); // 1,048,576
51
52 _maxFileSize = 33554432 * 10;
53 this->Core ((int)pow (2, 21)); // 2,097,152
54 this->Core ((int)pow (2, 22)); // 4,194,304
55 this->Core ((int)pow (2, 23)); // 8,388,608
56 this->Core ((int)pow (2, 24)); // 16,777,216
57 this->Core ((int)pow (2, 25)); // 33,554,432
58
59 return TRUE;
60}
61
62BOOL FilePerformanceCheck::Core (const int param1)
63{
64 this->Core1 (param1);
65 this->Core2 (param1);
66
67 return TRUE;
68}
69
70BOOL FilePerformanceCheck::Core1 (const int param1)
71{
73
74 Q.Start ();
75
76 alt::File file;
77 BYTE* byDummy = new BYTE[param1];
78 ZeroMemory (byDummy, param1 * sizeof (BYTE));
79 int writeSize = 0;
80
81 file.Create (_T (".\\test.bin"), GENERIC_WRITE, FILE_SHARE_WRITE, CREATE_ALWAYS);
82
83 while (writeSize < _maxFileSize)
84 {
85 DWORD dwWritten = file.Write (byDummy, param1 * sizeof (BYTE));
86 writeSize += dwWritten;
87 }
88
89 file.Close ();
90
91 delete[] byDummy;
92
93 Q.Stop ();
94
95 double writePerformance = ((writeSize / 1024 / 1024) / (Q.PastTime () / 1000));
96
97 _console.Format (_T ("%10dbytes単位の書き込み 書き込み量:%10d 書き込み時間:%10.4fmsec 結果:%9.4fMBytes/sec\n"),
98 param1, writeSize, Q.PastTime (), writePerformance);
99
100 return TRUE;
101}
102
103BOOL FilePerformanceCheck::Core2 (const int param1)
104{
106
107 Q.Start ();
108
109 alt::File file;
110 BYTE* byDummy = new BYTE[param1];
111 ZeroMemory (byDummy, param1 * sizeof (BYTE));
112 int readSize = 0;
113
114 file.Create (_T (".\\test.bin"), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING);
115
116 while (readSize < _maxFileSize)
117 {
118 DWORD dwRead = file.Read (byDummy, param1 * sizeof (BYTE));
119 readSize += dwRead;
120 }
121
122 file.Close ();
123
124 delete[] byDummy;
125
126 Q.Stop ();
127
128 double readPerformance = ((readSize / 1024 / 1024) / (Q.PastTime () / 1000));
129
130 _console.Format (_T ("%10dbytes単位の書き込み 書き込み量:%10d 書き込み時間:%10.4fmsec 結果:%9.4fMBytes/sec\n"),
131 param1, readSize, Q.PastTime (), readPerformance);
132
133 return TRUE;
134}
Fileクラス性能測定用
プリコンパイル済みヘッダー ファイルです。
virtual BOOL Core(const int param1)
FilePerformanceCheck(alt::Console &console)
virtual BOOL DoAction()
処理開始
virtual BOOL Core2(const int param1)
virtual BOOL Core1(const int param1)
コンソールに関するクラス
Definition: Console.h:88
VOID APIENTRY Format(LPCTSTR format,...) const
コンソールに文字を出力します。
Definition: Console.cpp:63
ファイルIOに関するWindowsAPIを集約したクラス
Definition: File.h:16
BOOL APIENTRY Create(LPCTSTR lpctszFileName, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationDisposition)
ファイルを作成、オープンします。
Definition: File.cpp:12
BOOL APIENTRY Close()
使用しなくなったハンドルはこれでクローズします。
高分解能時間計測クラス
VOID APIENTRY Start()
計測を開始します。
double APIENTRY PastTime() const
計測開始〜計測終了までの時間を出力します。
VOID APIENTRY Stop()
計測を終了します。
DWORD APIENTRY Read(LPVOID lpvBuffer, DWORD dwSize) const
HANDLEを使ってデータを読み込みます。
DWORD APIENTRY Write(LPCVOID lpcvBuffer, DWORD dwSize) const
HANDLEを使ってデータを書き込みます。