Skip to content

Commit

Permalink
merge bitcoin#24252: Represent paths with fs::path instead of std::st…
Browse files Browse the repository at this point in the history
…ring
  • Loading branch information
kwvg authored and PastaPastaPasta committed Aug 13, 2024
1 parent e416155 commit 357d1b6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 5 additions & 6 deletions src/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ const std::function<void(const std::string&)> G_TEST_LOG_FUN{};

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
Expand Down
5 changes: 3 additions & 2 deletions src/bench/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef BITCOIN_BENCH_BENCH_H
#define BITCOIN_BENCH_BENCH_H

#include <fs.h>
#include <util/macros.h>

#include <chrono>
Expand Down Expand Up @@ -44,8 +45,8 @@ struct Args {
std::string regex_filter;
bool is_list_only;
std::vector<double> asymptote;
std::string output_csv;
std::string output_json;
fs::path output_csv;
fs::path output_json;
};

class BenchRunner
Expand Down
5 changes: 3 additions & 2 deletions src/bench/bench_bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <bench/bench.h>

#include <crypto/sha256.h>
#include <fs.h>
#include <stacktraces.h>
#include <util/strencodings.h>
#include <util/system.h>
Expand Down Expand Up @@ -57,8 +58,8 @@ int main(int argc, char** argv)
args.regex_filter = argsman.GetArg("-filter", DEFAULT_BENCH_FILTER);
args.is_list_only = argsman.GetBoolArg("-list", false);
args.asymptote = parseAsymptote(argsman.GetArg("-asymptote", ""));
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", ""));

benchmark::BenchRunner::RunAll(args);

Expand Down

0 comments on commit 357d1b6

Please sign in to comment.