Skip to content

Commit 372cb6c

Browse files
committed
Merge bitcoin/bitcoin#24252: bench: Represent paths with fs::path instead of std::string
824e1ff bench: Represents paths with fs::path instead of std::string (Ryan Ofsky) Pull request description: Suggested bitcoin/bitcoin#20744 (comment) ACKs for top commit: fanquake: untested ACK 824e1ff hebasto: ACK 824e1ff, tested on Linux Mint 20.2 (x86_64). Tree-SHA512: 348fc189f30b5ad9a8e49e95e535d2c044462a9d534c3f34d887fbde0c05c41e88e02b4fc340709e6395a1188496a8333eb9e734310aa4c41755ec080e53c06e
2 parents b2a8371 + 824e1ff commit 372cb6c

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/bench/bench.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,19 @@ const std::function<std::vector<const char*>()> G_TEST_COMMAND_LINE_ARGUMENTS{};
2424

2525
namespace {
2626

27-
void GenerateTemplateResults(const std::vector<ankerl::nanobench::Result>& benchmarkResults, const std::string& filename, const char* tpl)
27+
void GenerateTemplateResults(const std::vector<ankerl::nanobench::Result>& benchmarkResults, const fs::path& file, const char* tpl)
2828
{
29-
if (benchmarkResults.empty() || filename.empty()) {
29+
if (benchmarkResults.empty() || file.empty()) {
3030
// nothing to write, bail out
3131
return;
3232
}
33-
std::ofstream fout{fs::PathFromString(filename)};
33+
std::ofstream fout{file};
3434
if (fout.is_open()) {
3535
ankerl::nanobench::render(tpl, benchmarkResults, fout);
36+
std::cout << "Created " << file << std::endl;
3637
} else {
37-
std::cout << "Could write to file '" << filename << "'" << std::endl;
38+
std::cout << "Could not write to file " << file << std::endl;
3839
}
39-
40-
std::cout << "Created '" << filename << "'" << std::endl;
4140
}
4241

4342
} // namespace

src/bench/bench.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef BITCOIN_BENCH_BENCH_H
66
#define BITCOIN_BENCH_BENCH_H
77

8+
#include <fs.h>
89
#include <util/macros.h>
910

1011
#include <chrono>
@@ -44,8 +45,8 @@ struct Args {
4445
bool is_list_only;
4546
std::chrono::milliseconds min_time;
4647
std::vector<double> asymptote;
47-
std::string output_csv;
48-
std::string output_json;
48+
fs::path output_csv;
49+
fs::path output_json;
4950
std::string regex_filter;
5051
};
5152

src/bench/bench_bitcoin.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <clientversion.h>
88
#include <crypto/sha256.h>
9+
#include <fs.h>
910
#include <util/strencodings.h>
1011
#include <util/system.h>
1112

@@ -108,8 +109,8 @@ int main(int argc, char** argv)
108109
args.asymptote = parseAsymptote(argsman.GetArg("-asymptote", ""));
109110
args.is_list_only = argsman.GetBoolArg("-list", false);
110111
args.min_time = std::chrono::milliseconds(argsman.GetIntArg("-min_time", DEFAULT_MIN_TIME_MS));
111-
args.output_csv = argsman.GetArg("-output_csv", "");
112-
args.output_json = argsman.GetArg("-output_json", "");
112+
args.output_csv = fs::PathFromString(argsman.GetArg("-output_csv", ""));
113+
args.output_json = fs::PathFromString(argsman.GetArg("-output_json", ""));
113114
args.regex_filter = argsman.GetArg("-filter", DEFAULT_BENCH_FILTER);
114115

115116
benchmark::BenchRunner::RunAll(args);

0 commit comments

Comments
 (0)