mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-20 14:58:54 +00:00
Add state::get_axis_values_as_string for JSON output.
This commit is contained in:
@@ -182,7 +182,7 @@ void json_printer::do_print_benchmark_results(const benchmark_vector &benches)
|
||||
auto &st = states[state_index];
|
||||
|
||||
st["index"] = state_index;
|
||||
st["description"] = exec_state.get_short_description();
|
||||
st["description"] = exec_state.get_axis_values_as_string();
|
||||
st["device"] = exec_state.get_device()->get_id();
|
||||
st["type_config_index"] = exec_state.get_type_config_index();
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ const std::vector<summary> &state::get_summaries() const { return m_summaries; }
|
||||
|
||||
std::vector<summary> &state::get_summaries() { return m_summaries; }
|
||||
|
||||
std::string state::get_short_description(bool color) const
|
||||
std::string state::get_axis_values_as_string(bool color) const
|
||||
{
|
||||
// Returns fmt_style if color is true, otherwise no style flags.
|
||||
auto style = [&color](auto fmt_style) {
|
||||
@@ -161,10 +161,21 @@ std::string state::get_short_description(bool color) const
|
||||
}
|
||||
}
|
||||
|
||||
return fmt::to_string(buffer);
|
||||
}
|
||||
|
||||
std::string state::get_short_description(bool color) const
|
||||
{
|
||||
// Returns fmt_style if color is true, otherwise no style flags.
|
||||
auto style = [&color](auto fmt_style) {
|
||||
const fmt::text_style no_style;
|
||||
return color ? fmt_style : no_style;
|
||||
};
|
||||
|
||||
return fmt::format(
|
||||
"{} [{}]",
|
||||
fmt::format(style(fmt::emphasis::bold), "{}", m_benchmark.get().get_name()),
|
||||
fmt::to_string(buffer));
|
||||
this->get_axis_values_as_string(color));
|
||||
}
|
||||
|
||||
void state::add_element_count(std::size_t elements, std::string column_name)
|
||||
|
||||
@@ -176,6 +176,11 @@ struct state
|
||||
return m_axis_values;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Return a string of "axis_name1=input_string1 axis_name2=input_string2 ..."
|
||||
*/
|
||||
[[nodiscard]] std::string get_axis_values_as_string(bool color = false) const;
|
||||
|
||||
[[nodiscard]] const benchmark_base &get_benchmark() const
|
||||
{
|
||||
return m_benchmark;
|
||||
|
||||
Reference in New Issue
Block a user