diff options
author | fanquake <fanquake@gmail.com> | 2022-02-05 10:58:21 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-02-05 10:58:35 +0800 |
commit | 372cb6c18642e2f2c9c2c7215c1f8c3af7d638f6 (patch) | |
tree | 3307b3305d0cf8e9f946eb6a8049364edb777fa7 | |
parent | b2a8371913a85701759b5a2d59d46e15f28ba68f (diff) | |
parent | 824e1ffa9fd957d05e34f36abe381c2465d89702 (diff) |
Merge bitcoin/bitcoin#24252: bench: Represent paths with fs::path instead of std::string
824e1ffa9fd957d05e34f36abe381c2465d89702 bench: Represents paths with fs::path instead of std::string (Ryan Ofsky)
Pull request description:
Suggested https://github.com/bitcoin/bitcoin/pull/20744#issuecomment-1022486215
ACKs for top commit:
fanquake:
untested ACK 824e1ffa9fd957d05e34f36abe381c2465d89702
hebasto:
ACK 824e1ffa9fd957d05e34f36abe381c2465d89702, tested on Linux Mint 20.2 (x86_64).
Tree-SHA512: 348fc189f30b5ad9a8e49e95e535d2c044462a9d534c3f34d887fbde0c05c41e88e02b4fc340709e6395a1188496a8333eb9e734310aa4c41755ec080e53c06e
-rw-r--r-- | src/bench/bench.cpp | 11 | ||||
-rw-r--r-- | src/bench/bench.h | 5 | ||||
-rw-r--r-- | src/bench/bench_bitcoin.cpp | 5 |
3 files changed, 11 insertions, 10 deletions
diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp index 5c24b712a7..033d319750 100644 --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -24,20 +24,19 @@ const std::function<std::vector<const char*>()> G_TEST_COMMAND_LINE_ARGUMENTS{}; namespace { -void GenerateTemplateResults(const std::vector<ankerl::nanobench::Result>& benchmarkResults, const std::string& filename, const char* tpl) +void GenerateTemplateResults(const std::vector<ankerl::nanobench::Result>& benchmarkResults, const fs::path& file, const char* tpl) { - if (benchmarkResults.empty() || filename.empty()) { + if (benchmarkResults.empty() || file.empty()) { // nothing to write, bail out return; } - std::ofstream fout{fs::PathFromString(filename)}; + std::ofstream fout{file}; if (fout.is_open()) { ankerl::nanobench::render(tpl, benchmarkResults, fout); + std::cout << "Created " << file << std::endl; } else { - std::cout << "Could write to file '" << filename << "'" << std::endl; + std::cout << "Could not write to file " << file << std::endl; } - - std::cout << "Created '" << filename << "'" << std::endl; } } // namespace diff --git a/src/bench/bench.h b/src/bench/bench.h index b959111bc2..6634138beb 100644 --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_BENCH_BENCH_H #define BITCOIN_BENCH_BENCH_H +#include <fs.h> #include <util/macros.h> #include <chrono> @@ -44,8 +45,8 @@ struct Args { bool is_list_only; std::chrono::milliseconds min_time; std::vector<double> asymptote; - std::string output_csv; - std::string output_json; + fs::path output_csv; + fs::path output_json; std::string regex_filter; }; diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp index c6c706d77e..3f8bff4bcf 100644 --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -6,6 +6,7 @@ #include <clientversion.h> #include <crypto/sha256.h> +#include <fs.h> #include <util/strencodings.h> #include <util/system.h> @@ -108,8 +109,8 @@ int main(int argc, char** argv) args.asymptote = parseAsymptote(argsman.GetArg("-asymptote", "")); args.is_list_only = argsman.GetBoolArg("-list", false); args.min_time = std::chrono::milliseconds(argsman.GetIntArg("-min_time", DEFAULT_MIN_TIME_MS)); - args.output_csv = argsman.GetArg("-output_csv", ""); - args.output_json = argsman.GetArg("-output_json", ""); + args.output_csv = fs::PathFromString(argsman.GetArg("-output_csv", "")); + args.output_json = fs::PathFromString(argsman.GetArg("-output_json", "")); args.regex_filter = argsman.GetArg("-filter", DEFAULT_BENCH_FILTER); benchmark::BenchRunner::RunAll(args); |