Created
November 4, 2021 17:07
-
-
Save MolecularMatters/2f180706bb3412caaeb12270b4ae6b3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <stdio.h> | |
#include <chrono> | |
static const int COUNT = 50000u; | |
int main() | |
{ | |
DWORD charCount = MAX_PATH; | |
wchar_t processName[MAX_PATH] = { '\0' }; | |
::QueryFullProcessImageNameW(::GetCurrentProcess(), 0u, processName, &charCount); | |
printf("path: %ls\n", processName); | |
{ | |
auto start = std::chrono::steady_clock::now(); | |
size_t checksum = 0u; | |
for (int i = 0u; i < COUNT; ++i) | |
{ | |
::WIN32_FILE_ATTRIBUTE_DATA attributes = {}; | |
const BOOL success = ::GetFileAttributesExW(processName, GetFileExInfoStandard, &attributes); | |
if (success != FALSE) | |
{ | |
checksum += attributes.nFileSizeLow; | |
} | |
} | |
auto end = std::chrono::steady_clock::now(); | |
printf("SERIAL: Took %llu ms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()); | |
printf("checksum: %zu\n", checksum); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment