| 60 | } |
| 61 | |
| 62 | std::optional<std::ofstream> CreateCsvFile(std::string& processName) |
| 63 | { |
| 64 | // Setup csv file |
| 65 | time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); |
| 66 | tm local_time; |
| 67 | localtime_s(&local_time, &now); |
| 68 | std::ofstream csvFile; |
| 69 | std::string csvFileName = processName; |
| 70 | |
| 71 | try { |
| 72 | csvFileName += "_" + std::to_string(local_time.tm_year + 1900) + |
| 73 | std::to_string(local_time.tm_mon + 1) + |
| 74 | std::to_string(local_time.tm_mday + 1) + |
| 75 | std::to_string(local_time.tm_hour) + |
| 76 | std::to_string(local_time.tm_min) + |
| 77 | std::to_string(local_time.tm_sec) + ".csv"; |
| 78 | csvFile.open(csvFileName); |
| 79 | csvFile << "Application,ProcessID,SwapChainAddress,PresentRuntime," |
| 80 | "SyncInterval,PresentFlags,AllowsTearing,PresentMode," |
| 81 | "CPUFrameQPC,CPUDuration,CPUFramePacingStall," |
| 82 | "GPULatency,GPUDuration,GPUBusy,DisplayLatency," |
| 83 | "DisplayDuration,InputLatency"; |
| 84 | csvFile << std::endl; |
| 85 | return csvFile; |
| 86 | } |
| 87 | catch (const std::exception& e) { |
| 88 | std::cout |
| 89 | << "a standard exception was caught, with message '" |
| 90 | << e.what() << "'" << std::endl; |
| 91 | return std::nullopt; |
| 92 | } |
| 93 | catch (...) { |
| 94 | std::cout << "Unknown Error" << std::endl; |
| 95 | return std::nullopt; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | int GenCsv(pmapi::Session& pSession, std::string processName, unsigned int processId) |
| 100 | { |