Alternate e697dbe9c5997e35395fe158628dd8c5209481da
for Visual Studio 2022 and Windows 11.
読み取り中…
検索中…
一致する文字列を見つけられません
StdFilePerformanceCheck.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 StdFilePerformanceCheck::Core (const int param1)
63{
64 this->Core1 (param1);
65 this->Core2 (param1);
66
67 return TRUE;
68}
69
70#pragma warning (push)
71#pragma warning (disable:6387)
72BOOL StdFilePerformanceCheck::Core1 (const int param1)
73{
75
76 Q.Start ();
77
78 FILE* fp;
79 BYTE* byDummy = new BYTE[param1];
80 ZeroMemory (byDummy, param1 * sizeof (BYTE));
81 size_t writeSize = 0;
82
83 errno_t errNo = fopen_s (&fp, ".\\test.bin", "wb");
84
85 while (writeSize < _maxFileSize)
86 {
87 size_t written = fwrite (byDummy, param1 * sizeof (BYTE), 1, fp);
88 writeSize += written;
89 }
90
91 fclose (fp);
92
93 delete[] byDummy;
94
95 Q.Stop ();
96
97 double writePerformance = ((writeSize / 1024 / 1024) / (Q.PastTime () / 1000));
98
99 _console.Format (_T ("%10dbytes単位の書き込み 書き込み量:%10lld 書き込み時間:%10.4fmsec 結果:%9.4fMBytes/sec\n"),
100 param1, writeSize, Q.PastTime (), writePerformance);
101
102 return TRUE;
103}
104
105BOOL StdFilePerformanceCheck::Core2 (const int param1)
106{
108
109 Q.Start ();
110
111 FILE* fp;
112 BYTE* byDummy = new BYTE[param1];
113 ZeroMemory (byDummy, param1 * sizeof (BYTE));
114 size_t readSize = 0;
115
116 errno_t errNo = fopen_s (&fp, ".\\test.bin", "rb");
117
118 while (readSize < _maxFileSize)
119 {
120 size_t read = fread (byDummy, param1 * sizeof (BYTE), 1, fp);
121 readSize += read;
122 }
123
124 fclose (fp);
125
126 delete[] byDummy;
127
128 Q.Stop ();
129
130 double readPerformance = ((readSize / 1024 / 1024) / (Q.PastTime () / 1000));
131
132 _console.Format (_T ("%10dbytes単位の読み込み 読み込み量:%10lld 読み込み時間:%10.4fmsec 結果:%9.4fMBytes/sec\n"),
133 param1, readSize, Q.PastTime (), readPerformance);
134
135 return TRUE;
136}
137#pragma warning (pop)
Fileクラスの比較用
プリコンパイル済みヘッダー ファイルです。
virtual BOOL Core1(const int param1)
virtual BOOL Core(const int param1)
virtual BOOL Core2(const int param1)
コンソールに関するクラス
Definition: Console.h:88
VOID APIENTRY Format(LPCTSTR format,...) const
コンソールに文字を出力します。
Definition: Console.cpp:63
高分解能時間計測クラス
VOID APIENTRY Start()
計測を開始します。
double APIENTRY PastTime() const
計測開始〜計測終了までの時間を出力します。
VOID APIENTRY Stop()
計測を終了します。