Skip to content

Commit

Permalink
bench: Represents paths with fs::path instead of std::string
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanofsky committed Feb 3, 2022
1 parent 3ace3a1 commit 3278e64
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/bench/bench.cpp
Expand Up @@ -24,13 +24,13 @@ 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& filename, const char* tpl)
{
if (benchmarkResults.empty() || filename.empty()) {
// nothing to write, bail out
return;
}
std::ofstream fout{fs::PathFromString(filename)};
std::ofstream fout{filename};
if (fout.is_open()) {
ankerl::nanobench::render(tpl, benchmarkResults, fout);
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/bench/bench.h
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 {
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;
};

Expand Down
5 changes: 3 additions & 2 deletions src/bench/bench_bitcoin.cpp
Expand Up @@ -6,6 +6,7 @@

#include <clientversion.h>
#include <crypto/sha256.h>
#include <fs.h>
#include <util/strencodings.h>
#include <util/system.h>

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3278e64

Please sign in to comment.