Commit c251c4cc authored by gabime's avatar gabime

Added the all flag to bench formatter

parent 0ce670e4
...@@ -28,9 +28,7 @@ void bench_formatter(benchmark::State &state, std::string pattern) ...@@ -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() ...@@ -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();
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment