mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
clang-format
This commit is contained in:
parent
70d03fd9c3
commit
50648553cf
@ -21,18 +21,16 @@ void bench_scoped_pad(benchmark::State &state, size_t wrapped_size, spdlog::deta
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bench_formatter(benchmark::State &state, std::string pattern)
|
||||
{
|
||||
auto formatter = spdlog::details::make_unique<spdlog::pattern_formatter>(pattern);
|
||||
fmt::memory_buffer dest;
|
||||
std::string logger_name = "logger-name";
|
||||
const char* text = "Hello. This is some message with length of 80 ";
|
||||
|
||||
const char *text = "Hello. This is some message with length of 80 ";
|
||||
|
||||
spdlog::details::log_msg msg(&logger_name, spdlog::level::info, text);
|
||||
// formatter->format(msg, dest);
|
||||
// printf("%s\n", fmt::to_string(dest).c_str());
|
||||
// formatter->format(msg, dest);
|
||||
// printf("%s\n", fmt::to_string(dest).c_str());
|
||||
|
||||
for (auto _ : state)
|
||||
{
|
||||
@ -47,46 +45,43 @@ void bench_formatters()
|
||||
// basic patterns(single flag)
|
||||
std::string all_flags = "+vtPnlLaAbBcCYDmdHIMSefFprRTXzEi%";
|
||||
std::vector<std::string> basic_patterns;
|
||||
for(auto &flag:all_flags)
|
||||
for (auto &flag : all_flags)
|
||||
{
|
||||
auto pattern = std::string("%") + flag;
|
||||
benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern);
|
||||
//bench left padding
|
||||
// bench left padding
|
||||
pattern = std::string("%16") + flag;
|
||||
benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern);
|
||||
|
||||
//bench center padding
|
||||
// bench center padding
|
||||
pattern = std::string("%=16") + flag;
|
||||
benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern);
|
||||
}
|
||||
|
||||
|
||||
// complex patterns
|
||||
std::vector<std::string> patterns = {
|
||||
"[%D %X] [%l] [%n] %v",
|
||||
"[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] %v",
|
||||
"[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] [%t] %v",
|
||||
"[%D %X] [%l] [%n] %v",
|
||||
"[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] %v",
|
||||
"[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] [%t] %v",
|
||||
};
|
||||
for(auto &pattern:patterns)
|
||||
for (auto &pattern : patterns)
|
||||
{
|
||||
benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern)->Iterations(2500000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
if(argc > 1) //bench given pattern
|
||||
if (argc > 1) // bench given pattern
|
||||
{
|
||||
std::string pattern = argv[1];
|
||||
benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern);
|
||||
}
|
||||
else //bench all flags
|
||||
else // bench all flags
|
||||
{
|
||||
bench_formatters();
|
||||
}
|
||||
benchmark::Initialize(&argc, argv);
|
||||
benchmark::RunSpecifiedBenchmarks();
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,6 @@ inline int pid()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Determine if the terminal supports colors
|
||||
// Source: https://github.com/agauniyal/rang/
|
||||
inline bool is_color_terminal() SPDLOG_NOEXCEPT
|
||||
|
@ -729,7 +729,8 @@ public:
|
||||
|
||||
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
|
||||
{
|
||||
if(padinfo_.width_) {
|
||||
if (padinfo_.width_)
|
||||
{
|
||||
scoped_pad p(msg.payload, padinfo_, dest);
|
||||
fmt_helper::append_string_view(msg.payload, dest);
|
||||
}
|
||||
|
@ -303,7 +303,6 @@ inline void critical(const wchar_t *fmt, const Args &... args)
|
||||
// SPDLOG_LEVEL_OFF
|
||||
//
|
||||
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
|
||||
#define SPDLOG_LOGGER_TRACE(logger, ...) logger->trace(__VA_ARGS__)
|
||||
#define SPDLOG_TRACE(...) spdlog::trace(__VA_ARGS__)
|
||||
|
Loading…
Reference in New Issue
Block a user