nanobench icon indicating copy to clipboard operation
nanobench copied to clipboard

[Feature Request] Mutable Benchmark Results

Open c0nstexpr opened this issue 5 months ago • 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.

c0nstexpr avatar Jan 17 '24 01:01 c0nstexpr