mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-20 06:48:53 +00:00
Allow benchmarks to be specified by index with --benchmark.
This commit is contained in:
@@ -357,7 +357,19 @@ void option_parser::print_list() const
|
||||
void option_parser::add_benchmark(const std::string &name)
|
||||
{
|
||||
const auto &mgr = nvbench::benchmark_manager::get();
|
||||
m_benchmarks.push_back(mgr.get_benchmark(name).clone());
|
||||
|
||||
std::unique_ptr<nvbench::benchmark_base> new_bench;
|
||||
|
||||
nvbench::int64_t idx{-1};
|
||||
try
|
||||
{
|
||||
::parse(name, idx);
|
||||
}
|
||||
catch (std::invalid_argument &)
|
||||
{}
|
||||
|
||||
m_benchmarks.push_back(idx >= 0 ? mgr.get_benchmark(idx).clone()
|
||||
: mgr.get_benchmark(name).clone());
|
||||
}
|
||||
|
||||
void option_parser::update_axis(const std::string &spec)
|
||||
|
||||
@@ -153,10 +153,19 @@ void test_benchmark_long() // --benchmark
|
||||
| 8 | 8 | U8 | F64 | 42 | 8 | 3.14 | 'S1' |
|
||||
)expected";
|
||||
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "1"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
}
|
||||
|
||||
void test_benchmark_short() // -b
|
||||
@@ -175,10 +184,19 @@ void test_benchmark_short() // -b
|
||||
| 8 | 8 | U8 | F64 | 42 | 8 | 3.14 | 'S1' |
|
||||
)expected";
|
||||
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"-b", "TestBench"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"-b", "TestBench"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"-b", "1"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
}
|
||||
|
||||
void test_int64_axis_single()
|
||||
|
||||
Reference in New Issue
Block a user