martinus/nanobench

[Feature Request] Mutable Benchmark Results

c0nstexpr opened this issue · 0 comments

Currently Result doesn't have any mutable method, which makes it hard to add custom variable or modify.
For example we have a relative(true) benchmark result and we would like to add the relative performance result. One may want to add it by setting the context varible, but find out context method is const.

ANKERL_NANOBENCH(NODISCARD) std::string const& Result::context(char const* variableName) const;
ANKERL_NANOBENCH(NODISCARD) std::string const& Result::context(std::string const& variableName) const;

A possible solution would be copy the result and use const_cast:
auto& context = const_cast<string&>(result.context("myVar"));
But I don't think anyone would totally accept to use that cast in such situation.