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

Function wmain

Tools/pm_convert_csv/pm_convert_csv.cpp:257–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257int wmain(
258 int argc,
259 wchar_t** argv)
260{
261 if (argc != 2) {
262 usage();
263 return 1;
264 }
265
266 std::wifstream file(argv[1]);
267 if (!file.is_open()) {
268 fprintf(stderr, "error: failed to open input file: %ls\n", argv[1]);
269 usage();
270 return 2;
271 }
272
273 SwapChains swapChains;
274
275 std::wstring line;
276 if (std::getline(file, line)) {
277 std::wstringstream ss(line);
278
279 if (line.size() >= 3 && line[0] == 0xef && line[1] == 0xbb && line[2] == 0xbf) {
280 ss.seekg(3);
281 }
282
283 uint32_t columnIndex[NumColumns];
284 for (uint32_t i = 0; i < NumColumns; ++i) {
285 columnIndex[i] = UINT32_MAX;
286 }
287
288 std::wstring word;
289 for (uint32_t i = 0; std::getline(ss, word, L','); ++i) {
290 if (word == L"Application") columnIndex[Application] = i;
291 else if (word == L"ProcessID") columnIndex[ProcessID] = i;
292 else if (word == L"SwapChainAddress") columnIndex[SwapChainAddress] = i;
293 else if (word == L"Runtime") columnIndex[Runtime] = i;
294 else if (word == L"SyncInterval") columnIndex[SyncInterval] = i;
295 else if (word == L"PresentFlags") columnIndex[PresentFlags] = i;
296 else if (word == L"Dropped") columnIndex[Dropped] = i;
297 else if (word == L"TimeInSeconds") columnIndex[TimeInSeconds] = i;
298 else if (word == L"msInPresentAPI") columnIndex[msInPresentAPI] = i;
299 else if (word == L"msBetweenPresents") columnIndex[msBetweenPresents] = i;
300 else if (word == L"AllowsTearing") columnIndex[AllowsTearing] = i;
301 else if (word == L"PresentMode") columnIndex[PresentMode] = i;
302 else if (word == L"msUntilRenderComplete") columnIndex[msUntilRenderComplete] = i;
303 else if (word == L"msUntilDisplayed") columnIndex[msUntilDisplayed] = i;
304 else if (word == L"msBetweenDisplayChange")columnIndex[msBetweenDisplayChange] = i;
305 else if (word == L"msUntilRenderStart") columnIndex[msUntilRenderStart] = i;
306 else if (word == L"msGPUActive") columnIndex[msGPUActive] = i;
307 else if (word == L"msGPUVideoActive") columnIndex[msGPUVideoActive] = i;
308 else if (word == L"msSinceInput") columnIndex[msSinceInput] = i;
309 else if (word == L"QPCTime") columnIndex[QPCTime] = i;
310 else if (word == L"WasBatched") columnIndex[WasBatched] = i;
311 else if (word == L"DwmNotified") columnIndex[DwmNotified] = i;
312 else {
313 fprintf(stderr, "error: unrecognised column: %ls\n", word.c_str());
314 return 3;

Callers

nothing calls this directly

Calls 6

WriteCsvHeaderFunction · 0.85
ReportMetricsFunction · 0.85
emptyMethod · 0.80
push_backMethod · 0.80
usageFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected