Commit e601ebe1 authored by gabime's avatar gabime

Updated formatter-bench

parent 7068c451
...@@ -50,9 +50,17 @@ void bench_formatters() ...@@ -50,9 +50,17 @@ void bench_formatters()
for(auto &flag:all_flags) for(auto &flag:all_flags)
{ {
auto pattern = std::string("%") + flag; auto pattern = std::string("%") + flag;
benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern)->Iterations(2500000); benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern);
//bench left padding
pattern = std::string("%16") + flag;
benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern);
//bench center padding
pattern = std::string("%=16") + flag;
benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern);
} }
// complex patterns // complex patterns
std::vector<std::string> patterns = { std::vector<std::string> patterns = {
"[%D %X] [%l] [%n] %v", "[%D %X] [%l] [%n] %v",
...@@ -65,34 +73,19 @@ void bench_formatters() ...@@ -65,34 +73,19 @@ void bench_formatters()
} }
} }
void bench_padders()
int main(int argc, char *argv[])
{ {
using spdlog::details::padding_info;
std::vector<size_t> sizes = {0, 2, 4, 8, 16, 32, 64, 128};
for (auto size : sizes) if(argc > 1) //bench given pattern
{ {
size_t wrapped_size = 8; std::string pattern = argv[1];
size_t padding_size = wrapped_size + size; benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern);
}
std::string title = "scoped_pad::left::" + std::to_string(size); else //bench all flags
{
benchmark::RegisterBenchmark(title.c_str(), bench_scoped_pad, wrapped_size, padding_info(padding_size, padding_info::left)); bench_formatters();
title = "scoped_pad::right::" + std::to_string(size);
benchmark::RegisterBenchmark(title.c_str(), bench_scoped_pad, wrapped_size, padding_info(padding_size, padding_info::right));
title = "scoped_pad::center::" + std::to_string(size);
benchmark::RegisterBenchmark(title.c_str(), bench_scoped_pad, wrapped_size, padding_info(padding_size, padding_info::center));
} }
}
int main(int argc, char *argv[])
{
bench_formatters();
//bench_padders();
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