test/perf: add fmt::formatters for scheduling_latency_measurer and perf_result

before this change, we rely on the default-generated fmt::formatter
created from operator<<, but fmt v10 dropped the default-generated
formatter.

in this change, we define formatters for

* scheduling_latency_measurer
* perf_result

and drop their operator<<:s

Refs #13245

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
Kefu Chai
2024-02-23 08:45:26 +08:00
parent 57c408ab5d
commit 2ccd9e695d
2 changed files with 15 additions and 9 deletions

View File

@@ -30,11 +30,12 @@ void scheduling_latency_measurer::schedule_tick() {
}));
}
std::ostream& operator<<(std::ostream& out, const scheduling_latency_measurer& slm) {
auto fmt::formatter<scheduling_latency_measurer>::format(const scheduling_latency_measurer& slm, fmt::format_context& ctx) const
-> decltype(ctx.out()) {
auto to_ms = [] (int64_t nanos) {
return float(nanos) / 1e6;
};
return out << fmt::format("{{count: {}, "
return fmt::format_to(ctx.out(), "{{count: {}, "
//"min: {:.6f} [ms], "
//"50%: {:.6f} [ms], "
//"90%: {:.6f} [ms], "
@@ -48,11 +49,10 @@ std::ostream& operator<<(std::ostream& out, const scheduling_latency_measurer& s
to_ms(slm.max().count()));
}
std::ostream&
operator<<(std::ostream& os, const perf_result& result) {
fmt::print(os, "{:.2f} tps ({:5.1f} allocs/op, {:5.1f} tasks/op, {:7.0f} insns/op, {:8} errors)",
auto fmt::formatter<perf_result>::format(const perf_result& result, fmt::format_context& ctx) const
-> decltype(ctx.out()) {
return fmt::format_to(ctx.out(), "{:.2f} tps ({:5.1f} allocs/op, {:5.1f} tasks/op, {:7.0f} insns/op, {:8} errors)",
result.throughput, result.mallocs_per_op, result.tasks_per_op, result.instructions_per_op, result.errors);
return os;
}
aio_writes_result_mixin::aio_writes_result_mixin()

View File

@@ -157,8 +157,6 @@ struct perf_result {
uint64_t errors;
};
std::ostream& operator<<(std::ostream& os, const perf_result& result);
// Use to make a perf_result with aio_writes added. Need to give "update" as
// update-func to time_parallel_ex to make it work.
struct aio_writes_result_mixin {
@@ -213,7 +211,7 @@ std::vector<Res> time_parallel_ex(Func func, unsigned concurrency_per_core, int
uf(result, stats);
std::cout << result << std::endl;
fmt::print("{}\n", result);
results.emplace_back(result);
}
return results;
@@ -282,3 +280,11 @@ public:
};
} // namespace perf
template <> struct fmt::formatter<scheduling_latency_measurer> : fmt::formatter<std::string_view> {
auto format(const scheduling_latency_measurer&, fmt::format_context& ctx) const -> decltype(ctx.out());
};
template <> struct fmt::formatter<perf_result> : fmt::formatter<std::string_view> {
auto format(const perf_result&, fmt::format_context& ctx) const -> decltype(ctx.out());
};