diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 1b8b9129..f1f9e742 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -281,7 +281,7 @@ void VulkanExampleBase::benchmarkLoop() } vkDeviceWaitIdle(device); // Save results as comma separated file - std::ofstream result("benchresults.csv", std::ios::out); + std::ofstream result(benchmark.resultFile + ".csv", std::ios::out); if (result.is_open()) { double tMin = *std::min_element(benchmark.iterationTime.begin(), benchmark.iterationTime.end()); @@ -698,16 +698,17 @@ VulkanExampleBase::VulkanExampleBase(bool enableValidation) } if ((args[i] == std::string("-b")) || (args[i] == std::string("-benchmark"))) { benchmark.active = true; - // Number of iterations as optional parameter + // Result file name can be overriden if (args.size() > i + 1) { - char* endptr; - uint32_t iterations = strtol(args[i + 1], &endptr, 10); - if (endptr != args[i + 1]) { benchmark.iterations = iterations; }; + benchmark.resultFile = args[i + 1]; } - benchmark.iterationTime.resize(benchmark.iterations); - benchmark.frameTimes.min = std::numeric_limits::max(); - benchmark.frameTimes.max = std::numeric_limits::min(); - benchmark.frameTimes.avg = 0.0; + // Number of iterations as optional parameter + if (args.size() > i + 2) { + char* endptr; + uint32_t iterations = strtol(args[i + 2], &endptr, 10); + if (endptr != args[i + 2]) { benchmark.iterations = iterations; }; + } + benchmark.init(); } } diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 431f6ac9..f5faa16b 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -156,10 +156,17 @@ public: bool active = false; uint32_t iterations = 10; uint32_t currIteration = 0; + std::string resultFile = "benchmarkresults"; std::vector iterationTime; struct FrameTimes { double min, max, avg; } frameTimes; + void init() { + iterationTime.resize(iterations); + frameTimes.min = std::numeric_limits::max(); + frameTimes.max = std::numeric_limits::min(); + frameTimes.avg = 0.0; + } } benchmark; float zoom = 0;