| 168 | } |
| 169 | |
| 170 | int FrameQuerySample(std::unique_ptr<pmapi::Session>&& pSession, bool genCsv) |
| 171 | { |
| 172 | using namespace std::chrono_literals; |
| 173 | using namespace pmapi; |
| 174 | |
| 175 | try { |
| 176 | |
| 177 | std::optional<unsigned int> processId; |
| 178 | std::optional<std::string> processName; |
| 179 | |
| 180 | GetProcessInformation(processName, processId); |
| 181 | if (!processId.has_value()) |
| 182 | { |
| 183 | std::cout << "Must set valid process name or process id:\n"; |
| 184 | std::cout << "--dynamic-query-sample [--process-id id | --process-name name.exe] [--gen-csv]\n"; |
| 185 | return -1; |
| 186 | } |
| 187 | |
| 188 | auto& opt = clio::Options::Get(); |
| 189 | if (genCsv) { |
| 190 | return GenCsv(*pSession, processName.value(), processId.value()); |
| 191 | } |
| 192 | |
| 193 | auto processTracker = pSession->TrackProcess(processId.value()); |
| 194 | |
| 195 | PM_BEGIN_FIXED_FRAME_QUERY(MyFrameQuery) |
| 196 | FixedQueryElement swapChain{ this, PM_METRIC_SWAP_CHAIN_ADDRESS, PM_STAT_NONE }; |
| 197 | FixedQueryElement cpuFrameQpc{ this, PM_METRIC_CPU_START_QPC, PM_STAT_NONE }; |
| 198 | FixedQueryElement cpuDuration{ this, PM_METRIC_CPU_FRAME_TIME, PM_STAT_NONE }; |
| 199 | FixedQueryElement cpuFpStall{ this, PM_METRIC_CPU_WAIT, PM_STAT_NONE }; |
| 200 | FixedQueryElement gpuLatency{ this, PM_METRIC_GPU_LATENCY, PM_STAT_NONE }; |
| 201 | FixedQueryElement gpuDuration{ this, PM_METRIC_GPU_TIME, PM_STAT_NONE }; |
| 202 | FixedQueryElement gpuBusyTime{ this, PM_METRIC_GPU_BUSY, PM_STAT_NONE }; |
| 203 | FixedQueryElement gpuDisplayLatency{ this, PM_METRIC_DISPLAY_LATENCY, PM_STAT_NONE }; |
| 204 | FixedQueryElement gpuDisplayDuration{ this, PM_METRIC_DISPLAYED_TIME, PM_STAT_NONE}; |
| 205 | FixedQueryElement animationError{ this, PM_METRIC_ANIMATION_ERROR, PM_STAT_NONE}; |
| 206 | FixedQueryElement inputLatency{ this, PM_METRIC_CLICK_TO_PHOTON_LATENCY, PM_STAT_NONE }; |
| 207 | FixedQueryElement gpuPower{ this, PM_METRIC_GPU_POWER, PM_STAT_NONE, 1 }; |
| 208 | FixedQueryElement presentRuntime{ this, PM_METRIC_PRESENT_RUNTIME, PM_STAT_NONE }; |
| 209 | FixedQueryElement fanSpeed{ this, PM_METRIC_GPU_FAN_SPEED, PM_STAT_NONE, 1 }; |
| 210 | PM_END_FIXED_QUERY fq{ *pSession, 20, 1 }; |
| 211 | |
| 212 | while (!_kbhit()) { |
| 213 | std::cout << "Consuming frames...\n"; |
| 214 | const auto nProcessed = fq.ForEachConsume(processTracker, [processName, processId, &fq] { |
| 215 | std::cout << processName.value() << ","; |
| 216 | std::cout << processId.value() << ","; |
| 217 | std::cout << std::hex << "0x" << fq.swapChain.As<uint64_t>() << std::dec << ","; |
| 218 | std::cout << fq.cpuFrameQpc.As<uint64_t>() << ","; |
| 219 | std::cout << fq.cpuDuration.As<double>() << ","; |
| 220 | std::cout << fq.cpuFpStall.As<double>() << ","; |
| 221 | std::cout << fq.gpuLatency.As<double>() << ","; |
| 222 | std::cout << fq.gpuDuration.As<double>() << ","; |
| 223 | std::cout << fq.gpuBusyTime.As<double>() << ","; |
| 224 | std::cout << fq.gpuDisplayLatency.As<double>() << ","; |
| 225 | std::cout << fq.gpuDisplayDuration.As<double>() << ","; |
| 226 | std::cout << fq.animationError.As<double>() << ","; |
| 227 | std::cout << fq.inputLatency.As<double>() << ","; |
no test coverage detected