From cba2dd96ec7b8e80465fee9b940dac1d60a87fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Tue, 22 Jan 2019 19:54:12 +0100 Subject: [PATCH] Allow specyfing more than one input file for sprite sort benchmark --- src/openrct2/cmdline/BenchSpriteSort.cpp | 48 ++++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/openrct2/cmdline/BenchSpriteSort.cpp b/src/openrct2/cmdline/BenchSpriteSort.cpp index 9d1d2c2898..0c9776ece8 100644 --- a/src/openrct2/cmdline/BenchSpriteSort.cpp +++ b/src/openrct2/cmdline/BenchSpriteSort.cpp @@ -159,24 +159,6 @@ static void BM_paint_session_arrange(benchmark::State& state, const std::vector< static int cmdline_for_bench_sprite_sort(int argc, const char** argv) { - const char* inputFileName = nullptr; - int argStart = 0; - if (argc >= 1 && platform_file_exists(argv[0])) - { - inputFileName = argv[0]; - argStart = 1; // skip file name - } - // Google benchmark does stuff to argv. It doesn't modify the pointees, - // but it wants to reorder the pointers, so present a copy of them. - std::vector argv_for_benchmark; - // argv[0] is expected to contain the binary name. It's only for logging purposes, don't bother. - argv_for_benchmark.push_back(nullptr); - for (int i = argStart; i < argc; i++) - { - argv_for_benchmark.push_back((char*)argv[i]); - } - // Update argc with all the changes made - argc = (int)argv_for_benchmark.size(); { // Register some basic "baseline" benchmark std::vector sessions(1); @@ -190,13 +172,31 @@ static int cmdline_for_bench_sprite_sort(int argc, const char** argv) } benchmark::RegisterBenchmark("baseline", BM_paint_session_arrange, sessions); } - if (inputFileName != nullptr) + + // Google benchmark does stuff to argv. It doesn't modify the pointees, + // but it wants to reorder the pointers, so present a copy of them. + std::vector argv_for_benchmark; + + // argv[0] is expected to contain the binary name. It's only for logging purposes, don't bother. + argv_for_benchmark.push_back(nullptr); + + // Extract file names from argument list. If there is no such file, consider it benchmark option. + for (int i = 0; i < argc; i++) { - // Register benchmark for sv6 if valid - std::vector sessions = extract_paint_session(inputFileName); - if (!sessions.empty()) - benchmark::RegisterBenchmark(inputFileName, BM_paint_session_arrange, sessions); + if (platform_file_exists(argv[i])) + { + // Register benchmark for sv6 if valid + std::vector sessions = extract_paint_session(argv[i]); + if (!sessions.empty()) + benchmark::RegisterBenchmark(argv[i], BM_paint_session_arrange, sessions); + } + else + { + argv_for_benchmark.push_back((char*)argv[i]); + } } + // Update argc with all the changes made + argc = (int)argv_for_benchmark.size(); ::benchmark::Initialize(&argc, &argv_for_benchmark[0]); if (::benchmark::ReportUnrecognizedArguments(argc, &argv_for_benchmark[0])) return -1; @@ -228,7 +228,7 @@ const CommandLineCommand CommandLine::BenchSpriteSortCommands[]{ #ifdef USE_BENCHMARK DefineCommand( "", - "[] [--benchmark_list_tests={true|false}] [--benchmark_filter=] [--benchmark_min_time=] " + "[]... [--benchmark_list_tests={true|false}] [--benchmark_filter=] [--benchmark_min_time=] " "[--benchmark_repetitions=] [--benchmark_report_aggregates_only={true|false}] " "[--benchmark_format=] [--benchmark_out=] [--benchmark_out_format=] " "[--benchmark_color={auto|true|false}] [--benchmark_counters_tabular={true|false}] [--v=]",