From cb32e2e89f8b168626a849a57490497b5a286a20 Mon Sep 17 00:00:00 2001 From: saschawillems Date: Sat, 13 Jan 2018 10:39:03 +0100 Subject: [PATCH] Separated benchmark argument line options Refs #269 --- base/benchmark.hpp | 6 +++--- base/vulkanexamplebase.cpp | 32 +++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/base/benchmark.hpp b/base/benchmark.hpp index f37a5879..c34d1599 100644 --- a/base/benchmark.hpp +++ b/base/benchmark.hpp @@ -21,7 +21,7 @@ namespace vks FILE *stream; public: bool active = false; - bool outputFrameTimes = true; + bool outputFrameTimes = false; uint32_t warmup = 1; uint32_t duration = 10; std::vector frameTimes; @@ -72,8 +72,8 @@ namespace vks if (result.is_open()) { result << std::fixed << std::setprecision(4); - result << "duration (ms),frames" << std::endl; - result << runtime << "," << frameCount << std::endl; + result << "duration (ms),frames,fps" << std::endl; + result << runtime << "," << frameCount << "," << frameCount / (runtime / 1000.0) << std::endl; if (outputFrameTimes) { result << std::endl << "frame,ms" << std::endl; diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 9a40d683..fe1b6678 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -690,10 +690,12 @@ VulkanExampleBase::VulkanExampleBase(bool enableValidation) uint32_t h = strtol(args[i + 1], &numConvPtr, 10); if (numConvPtr != args[i + 1]) { height = h; }; } - if ((args[i] == std::string("-b")) || (args[i] == std::string("-benchmark"))) { - // TODO: option toggle for detailed frame rate output + // Benchmark + if ((args[i] == std::string("-b")) || (args[i] == std::string("--benchmark"))) { benchmark.active = true; - // Warmup time in seconds + } + // Warmup time (in seconds) + if ((args[i] == std::string("-bw")) || (args[i] == std::string("--benchwarmup"))) { if (args.size() > i + 1) { uint32_t num = strtol(args[i + 1], &numConvPtr, 10); if (numConvPtr != args[i + 1]) { @@ -702,25 +704,33 @@ VulkanExampleBase::VulkanExampleBase(bool enableValidation) std::cerr << "Warmup time for benchmark mode must be specified as a number!" << std::endl; } } - // Benchmark runtime in seconds - if (args.size() > i + 2) { - uint32_t num = strtol(args[i + 2], &numConvPtr, 10); - if (numConvPtr != args[i + 2]) { + } + // Benchmark runtime (in seconds) + if ((args[i] == std::string("-br")) || (args[i] == std::string("--benchruntime"))) { + if (args.size() > i + 1) { + uint32_t num = strtol(args[i + 1], &numConvPtr, 10); + if (numConvPtr != args[i + 1]) { benchmark.duration = num; } else { std::cerr << "Benchmark run duration must be specified as a number!" << std::endl; } } - // Default file name can be overriden - if (args.size() > i + 3) { - if (args[i + 3][0] == '-') { + } + // Bench result save filename (overrides default) + if ((args[i] == std::string("-bf")) || (args[i] == std::string("--benchfilename"))) { + if (args.size() > i + 1) { + if (args[i + 1][0] == '-') { std::cerr << "Filename for benchmark results must not start with a hyphen!" << std::endl; } else { - benchmark.filename = args[i + 3]; + benchmark.filename = args[i + 1]; } } } + // Output frame times to benchmark result file + if ((args[i] == std::string("-bt")) || (args[i] == std::string("--benchframetimes"))) { + benchmark.outputFrameTimes = true; + } } #if defined(VK_USE_PLATFORM_ANDROID_KHR)