Skip to content

Commit

Permalink
*improve WIN32 performance report.
Browse files Browse the repository at this point in the history
  • Loading branch information
ermig1979 committed Jul 4, 2023
1 parent 2e527d2 commit baed579
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/2023.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ <h1>Simd Library Release Notes (2023).</h1>
<a href="2013.html">2013</a>
</center>

<hr/>
<h3 id="R128">August X, 2023 (version X.X.128)</h3>

<h4>Test framework</h4>
<h5>Improving</h5>
<ul>
<li>WIN32 performance report.</li>
</ul>

<hr/>
<h3 id="R127">July 4, 2023 (version 5.3.127)</h3>
<h4>Algorithms</h4>
Expand Down
31 changes: 31 additions & 0 deletions src/Test/TestPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,23 @@ namespace Test
return "Simd Library Performance Report:";
}

#if defined(_WIN32)
static std::string Execute(const char* cmd)
{
std::shared_ptr<FILE> pipe(_popen(cmd, "r"), _pclose);
if (!pipe)
return "ERROR";
char buffer[MAX_PATH];
std::string result = "";
while (!feof(pipe.get()))
{
if (fgets(buffer, MAX_PATH, pipe.get()) != NULL)
result += buffer;
}
return result;
}
#endif

static String TestInfo(size_t threads)
{
std::stringstream info;
Expand All @@ -466,6 +483,20 @@ namespace Test
mem = mem.substr(0, mem.find('\n'));
::pclose(m);
}
#elif defined(_WIN32)
String cpuRaw = Execute("wmic cpu get Name /format:value");
size_t cpuBeg = cpuRaw.find('=') + 1;
size_t cpuEnd = cpuRaw.find('\r', cpuBeg);
while (cpuRaw[cpuEnd - 1] == ' ')
cpuEnd--;
cpu = cpuRaw.substr(cpuBeg, cpuEnd - cpuBeg);
MEMORYSTATUSEX memorystatusex;
memorystatusex.dwLength = sizeof(memorystatusex);
if (GlobalMemoryStatusEx(&memorystatusex) == TRUE)
{
double memGB = double(memorystatusex.ullTotalPhys) / 1024.0 / 1024.0 / 1024.0;
mem = ToString(memGB, 1, false);
}
#endif
info << std::endl;
info << "CPU: " << cpu;
Expand Down

0 comments on commit baed579

Please sign in to comment.