MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / WriteToCSV

Function WriteToCSV

IntelPresentMon/SampleClient/FrameQuerySample.h:5–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#pragma once
4
5void WriteToCSV(std::ofstream& csvFile, const std::string& processName, const unsigned int& processId,
6 PM_QUERY_ELEMENT(&queryElements)[16], pmapi::BlobContainer& blobs)
7{
8
9 try {
10
11 for (auto pBlob : blobs) {
12 //const auto appName = *reinterpret_cast<const std::string*>(&pBlob[queryElements[0].dataOffset]);
13 const auto swapChain = *reinterpret_cast<const uint64_t*>(&pBlob[queryElements[0].dataOffset]);
14 const auto graphicsRuntime = *reinterpret_cast<const PM_GRAPHICS_RUNTIME*>(&pBlob[queryElements[1].dataOffset]);
15 const auto syncInterval = *reinterpret_cast<const uint32_t*>(&pBlob[queryElements[2].dataOffset]);
16 const auto presentFlags = *reinterpret_cast<const uint32_t*>(&pBlob[queryElements[3].dataOffset]);
17 const auto allowsTearing = *reinterpret_cast<const bool*>(&pBlob[queryElements[4].dataOffset]);
18 const auto presentMode = *reinterpret_cast<const PM_PRESENT_MODE*>(&pBlob[queryElements[5].dataOffset]);
19 const auto cpuFrameQpc = *reinterpret_cast<const uint64_t*>(&pBlob[queryElements[6].dataOffset]);
20 const auto cpuDuration = *reinterpret_cast<const double*>(&pBlob[queryElements[7].dataOffset]);
21 const auto cpuFramePacingStall = *reinterpret_cast<const double*>(&pBlob[queryElements[8].dataOffset]);
22 const auto gpuLatency = *reinterpret_cast<const double*>(&pBlob[queryElements[9].dataOffset]);
23 const auto gpuDuration = *reinterpret_cast<const double*>(&pBlob[queryElements[10].dataOffset]);
24 const auto gpuBusyTime = *reinterpret_cast<const double*>(&pBlob[queryElements[11].dataOffset]);
25 const auto gpuDisplayLatency = *reinterpret_cast<const double*>(&pBlob[queryElements[12].dataOffset]);
26 const auto gpuDisplayDuration = *reinterpret_cast<const double*>(&pBlob[queryElements[13].dataOffset]);
27 const auto animationError = *reinterpret_cast<const double*>(&pBlob[queryElements[14].dataOffset]);
28 const auto inputLatency = *reinterpret_cast<const double*>(&pBlob[queryElements[15].dataOffset]);
29 csvFile << processName << ",";
30 csvFile << processId << ",";
31 csvFile << std::hex << "0x" << std::dec << swapChain << ",";
32 csvFile << TranslateGraphicsRuntime(graphicsRuntime) << ",";
33 csvFile << syncInterval << ",";
34 csvFile << presentFlags << ",";
35 csvFile << allowsTearing << ",";
36 csvFile << TranslatePresentMode(presentMode) << ",";
37 csvFile << cpuFrameQpc << ",";
38 csvFile << cpuDuration << ",";
39 csvFile << cpuFramePacingStall << ",";
40 csvFile << gpuLatency << ",";
41 csvFile << gpuDuration << ",";
42 csvFile << gpuBusyTime << ",";
43 csvFile << gpuDisplayLatency << ",";
44 csvFile << gpuDisplayDuration << ",";
45 csvFile << animationError << ",";
46 csvFile << inputLatency << "\n";
47 }
48 }
49 catch (const std::exception& e) {
50 std::cout
51 << "a standard exception was caught, with message '"
52 << e.what() << "'" << std::endl;
53 return;
54 }
55 catch (...) {
56 std::cout << "Unknown Error" << std::endl;
57 return;
58 }
59
60}
61
62std::optional<std::ofstream> CreateCsvFile(std::string& processName)

Callers 1

GenCsvFunction · 0.70

Calls 3

whatMethod · 0.80
TranslateGraphicsRuntimeFunction · 0.70
TranslatePresentModeFunction · 0.70

Tested by

no test coverage detected