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

Function GenCsv

IntelPresentMon/SampleClient/FrameQuerySample.h:99–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99int GenCsv(pmapi::Session& pSession, std::string processName, unsigned int processId)
100{
101 using namespace std::chrono_literals;
102
103 try
104 {
105 pmapi::ProcessTracker processTracker;
106 static constexpr uint32_t numberOfBlobs = 150u;
107
108 // TODO: Had to comment out the application metric because when
109 // calling RegisterFrameQuery we crash
110 PM_QUERY_ELEMENT queryElements[]{
111 //{ PM_METRIC_APPLICATION, PM_STAT_NONE, 0, 0 },
112 { PM_METRIC_SWAP_CHAIN_ADDRESS, PM_STAT_NONE, 0, 0 },
113 { PM_METRIC_PRESENT_RUNTIME, PM_STAT_NONE, 0, 0 },
114 { PM_METRIC_SYNC_INTERVAL, PM_STAT_NONE, 0, 0 },
115 { PM_METRIC_PRESENT_FLAGS, PM_STAT_NONE, 0, 0 },
116 { PM_METRIC_ALLOWS_TEARING, PM_STAT_NONE, 0, 0 },
117 { PM_METRIC_PRESENT_MODE, PM_STAT_NONE, 0, 0 },
118 { PM_METRIC_CPU_START_QPC, PM_STAT_NONE, 0, 0 },
119 { PM_METRIC_CPU_FRAME_TIME, PM_STAT_NONE, 0, 0 },
120 { PM_METRIC_CPU_WAIT, PM_STAT_NONE, 0, 0 },
121 { PM_METRIC_GPU_LATENCY, PM_STAT_NONE, 0, 0 },
122 { PM_METRIC_GPU_TIME, PM_STAT_NONE, 0, 0 },
123 { PM_METRIC_GPU_BUSY, PM_STAT_NONE, 0, 0},
124 { PM_METRIC_DISPLAY_LATENCY, PM_STAT_NONE, 0, 0 },
125 { PM_METRIC_DISPLAYED_TIME, PM_STAT_NONE, 0, 0 },
126 { PM_METRIC_ANIMATION_ERROR, PM_STAT_NONE, 0, 0 },
127 { PM_METRIC_CLICK_TO_PHOTON_LATENCY, PM_STAT_NONE, 0, 0}
128 };
129
130 auto frameQuery = pSession.RegisterFrameQuery(queryElements);
131 auto blobs = frameQuery.MakeBlobContainer(numberOfBlobs);
132
133 processTracker = pSession.TrackProcess(processId);
134
135 auto csvStream = CreateCsvFile(processName);
136 if (!csvStream.has_value())
137 {
138 return -1;
139 }
140
141 while (!_kbhit()) {
142 std::cout << "Checking for new frames...\n";
143 uint32_t numFrames = numberOfBlobs;
144 frameQuery.Consume(processTracker, blobs);
145 if (blobs.GetNumBlobsPopulated() == 0) {
146 std::this_thread::sleep_for(200ms);
147 }
148 else {
149 std::cout << std::format("Dumping [{}] frames...\n", numFrames);
150 WriteToCSV(csvStream.value(), processName, processId, queryElements, blobs);
151 }
152 }
153
154 processTracker.Reset();
155 //pSession->Reset();
156 csvStream.value().close();

Callers 1

FrameQuerySampleFunction · 0.85

Calls 9

RegisterFrameQueryMethod · 0.80
GetNumBlobsPopulatedMethod · 0.80
whatMethod · 0.80
CreateCsvFileFunction · 0.70
WriteToCSVFunction · 0.70
MakeBlobContainerMethod · 0.45
TrackProcessMethod · 0.45
ConsumeMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected