mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
Added the all flag to bench formatter
This commit is contained in:
parent
0ce670e45a
commit
c251c4ccbb
@ -28,9 +28,7 @@ void bench_formatter(benchmark::State &state, std::string pattern)
|
|||||||
std::string logger_name = "logger-name";
|
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(spdlog::source_loc{__FILE__, __LINE__}, &logger_name, spdlog::level::info, text);
|
spdlog::details::log_msg msg(&logger_name, spdlog::level::info, text);
|
||||||
// formatter->format(msg, dest);
|
|
||||||
// printf("%s\n", fmt::to_string(dest).c_str());
|
|
||||||
|
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
@ -73,15 +71,22 @@ void bench_formatters()
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
if (argc > 1) // bench given pattern
|
spdlog::set_pattern("[%^%l%$] %v");
|
||||||
|
if(argc != 2)
|
||||||
{
|
{
|
||||||
std::string pattern = argv[1];
|
spdlog::error("Usage: {} format-flag (or \"all\" to bench all)", argv[0]);
|
||||||
benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern);
|
exit(1);
|
||||||
}
|
}
|
||||||
else // bench all flags
|
|
||||||
|
std::string pattern = argv[1];
|
||||||
|
if(pattern == "all")
|
||||||
{
|
{
|
||||||
bench_formatters();
|
bench_formatters();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern);
|
||||||
|
}
|
||||||
benchmark::Initialize(&argc, argv);
|
benchmark::Initialize(&argc, argv);
|
||||||
benchmark::RunSpecifiedBenchmarks();
|
benchmark::RunSpecifiedBenchmarks();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user