Add new --version option to benchmark executables.

This commit is contained in:
Allison Vacanti
2021-10-19 17:50:31 -04:00
parent ef36d3a558
commit 27b23eeb46
2 changed files with 19 additions and 0 deletions

View File

@@ -21,10 +21,12 @@
#include <nvbench/benchmark_base.cuh>
#include <nvbench/benchmark_manager.cuh>
#include <nvbench/csv_printer.cuh>
#include <nvbench/git_revision.cuh>
#include <nvbench/json_printer.cuh>
#include <nvbench/markdown_printer.cuh>
#include <nvbench/printer_base.cuh>
#include <nvbench/range.cuh>
#include <nvbench/version.cuh>
#include <nvbench/detail/throw.cuh>
@@ -383,6 +385,11 @@ void option_parser::parse_range(option_parser::arg_iterator_t first,
this->print_help_axis();
std::exit(0);
}
else if (arg == "--version")
{
this->print_version();
std::exit(0);
}
else if (arg == "--list" || arg == "-l")
{
this->print_list();
@@ -531,6 +538,17 @@ std::ostream &option_parser::printer_spec_to_ostream(const std::string &spec)
}
}
void option_parser::print_version() const
{
fmt::print("NVBench v{}.{}.{} ({}:{})\n",
NVBENCH_VERSION_MAJOR,
NVBENCH_VERSION_MINOR,
NVBENCH_VERSION_PATCH,
NVBENCH_GIT_BRANCH,
NVBENCH_GIT_VERSION);
std::exit(0);
}
void option_parser::print_list() const
{
const auto &bench_mgr = nvbench::benchmark_manager::get();

View File

@@ -84,6 +84,7 @@ private:
std::ostream &printer_spec_to_ostream(const std::string &spec);
void print_version() const;
void print_list() const;
void print_help() const;
void print_help_axis() const;