Closed
Description
Version: fmt 5.2.1, Clang 6.0
Summary
Constructing fmt::string_view
with const char*
of size 515 bytes takes about ~180 ns under Clang, while under gcc it takes less than 1ns.
Cause
The cause is that https://github.com/fmtlib/fmt/blob/master/include/fmt/core.h@L217
FMT_CONSTEXPR size_t length(const char *s) { return std::strlen(s); }
is only enabled for gcc (why?) so clang ends up using the much slower implementation (https://github.com/fmtlib/fmt/blob/master/include/fmt/core.h@L210)
Just to be sure I tried to enable for clang as well, and performance went from 180 to 1ns:
#if FMT_GCC_VERSION || defined(__clang__)
FMT_CONSTEXPR size_t length(const char *s) { return std::strlen(s); }
#endif
Metadata
Metadata
Assignees
Labels
No labels