diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2022-02-03 10:53:57 -0500 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2022-02-04 09:33:41 -0500 |
commit | 824e1ffa9fd957d05e34f36abe381c2465d89702 (patch) | |
tree | 11a640541956c72fd6d4312ca3438d68a029ae86 /src/bench/bench.cpp | |
parent | 3ace3a17c9bce606cea05192f0da3ac62ac69dda (diff) | |
download | bitcoin-824e1ffa9fd957d05e34f36abe381c2465d89702.tar.xz |
bench: Represents paths with fs::path instead of std::string
Also uses fs::path quoting in bench printed strings and fixes a
misleading error message.
Originally suggested https://github.com/bitcoin/bitcoin/pull/20744#issuecomment-1022486215
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Diffstat (limited to 'src/bench/bench.cpp')
-rw-r--r-- | src/bench/bench.cpp | 11 |
1 files changed, 5 insertions, 6 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 |