Add format benchmarks

This commit is contained in:
2025-08-28 14:20:27 -04:00
parent 404b491880
commit 7808896226
3 changed files with 300 additions and 0 deletions

View File

@@ -254,6 +254,25 @@ inline constexpr int max_decimal_length_v = decltype(term(T{}))::kMaxLength;
inline constexpr DoubleTerm term(double s) { return DoubleTerm(s); }
// Runtime string term for std::string_view (works with std::string, const
// char*, etc.)
struct StringViewTerm {
explicit constexpr StringViewTerm(std::string_view s) : s(s) {}
static constexpr int kMaxLength =
512; // Conservative upper bound for runtime strings
void write(char *&buf) const {
std::memcpy(buf, s.data(), s.size());
buf += s.size();
}
private:
std::string_view s;
};
inline constexpr StringViewTerm term(std::string_view s) {
return StringViewTerm(s);
}
} // namespace detail
/**