From 8b51b3b2771378b4c66da5d986fc102831c67856 Mon Sep 17 00:00:00 2001 From: gabime Date: Wed, 5 Nov 2014 02:36:50 +0200 Subject: [PATCH 1/3] astyle --- bench-comparison/boost-bench-mt.cpp | 28 ++++++++-------- bench-comparison/boost-bench.cpp | 8 ++--- bench-comparison/spdlog-bench-mt.cpp | 32 +++++++++---------- bench-comparison/spdlog-bench.cpp | 12 +++---- .../spdlog/details/pattern_formatter_impl.h | 2 +- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/bench-comparison/boost-bench-mt.cpp b/bench-comparison/boost-bench-mt.cpp index 501fcdde..9867f30a 100644 --- a/bench-comparison/boost-bench-mt.cpp +++ b/bench-comparison/boost-bench-mt.cpp @@ -23,7 +23,7 @@ void init() keywords::file_name = "logs/boost-sample_%N.log", /*< file name pattern >*/ keywords::rotation_size = 10 * 1024 * 1024, /*< rotate files every 10 MiB... >*/ keywords::auto_flush = false, - keywords::format = "[%TimeStamp%]: %Message%" + keywords::format = "[%TimeStamp%]: %Message%" ); logging::core::get()->set_filter @@ -38,24 +38,24 @@ using namespace std; int main(int argc, char* argv[]) { - int thread_count = 10; - if(argc > 1) - thread_count = atoi(argv[1]); - - int howmany = 1000000; + int thread_count = 10; + if(argc > 1) + thread_count = atoi(argv[1]); + + int howmany = 1000000; + - init(); logging::add_common_attributes(); - + using namespace logging::trivial; - + src::severity_logger_mt< severity_level > lg; - + std::atomic msg_counter {0}; vector threads; - + for (int t = 0; t < thread_count; ++t) { threads.push_back(std::thread([&]() @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) { int counter = ++msg_counter; if (counter > howmany) break; - BOOST_LOG_SEV(lg, info) << "Boost logger message #" << counter; + BOOST_LOG_SEV(lg, info) << "Boost logger message #" << counter; } })); } @@ -74,7 +74,7 @@ int main(int argc, char* argv[]) { t.join(); }; - - + + return 0; } diff --git a/bench-comparison/boost-bench.cpp b/bench-comparison/boost-bench.cpp index 004279f2..31e13913 100644 --- a/bench-comparison/boost-bench.cpp +++ b/bench-comparison/boost-bench.cpp @@ -20,7 +20,7 @@ void init() keywords::file_name = "logs/boost-sample_%N.log", /*< file name pattern >*/ keywords::rotation_size = 10 * 1024 * 1024, /*< rotate files every 10 MiB... >*/ keywords::auto_flush = false, - keywords::format = "[%TimeStamp%]: %Message%" + keywords::format = "[%TimeStamp%]: %Message%" ); logging::core::get()->set_filter @@ -32,14 +32,14 @@ void init() int main(int argc, char* []) { - int howmany = 1000000; + int howmany = 1000000; init(); logging::add_common_attributes(); using namespace logging::trivial; src::severity_logger_mt< severity_level > lg; - for(int i = 0 ; i < howmany; ++i) - BOOST_LOG_SEV(lg, info) << "Boost logger message #" << i; + for(int i = 0 ; i < howmany; ++i) + BOOST_LOG_SEV(lg, info) << "Boost logger message #" << i; return 0; } diff --git a/bench-comparison/spdlog-bench-mt.cpp b/bench-comparison/spdlog-bench-mt.cpp index fafc0c5b..49304b92 100644 --- a/bench-comparison/spdlog-bench-mt.cpp +++ b/bench-comparison/spdlog-bench-mt.cpp @@ -6,26 +6,26 @@ #include using namespace std; - + int main(int argc, char* argv[]) { - int thread_count = 10; - if(argc > 1) - thread_count = atoi(argv[1]); - - int howmany = 1000000; + int thread_count = 10; + if(argc > 1) + thread_count = atoi(argv[1]); - namespace spd = spdlog; - ///Create a file rotating logger with 5mb size max and 3 rotated files + int howmany = 1000000; + + namespace spd = spdlog; + ///Create a file rotating logger with 5mb size max and 3 rotated files auto logger = spd::rotating_logger_mt("file_logger", "logs/spd-sample", 10 *1024 * 1024 , 5); - logger->set_pattern("[%Y-%b-%d %T.%e]: %v"); - - std::atomic msg_counter {0}; + logger->set_pattern("[%Y-%b-%d %T.%e]: %v"); + + std::atomic msg_counter {0}; vector threads; - - for (int t = 0; t < thread_count; ++t) + + for (int t = 0; t < thread_count; ++t) { threads.push_back(std::thread([&]() { @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) { int counter = ++msg_counter; if (counter > howmany) break; - logger->info() << "spdlog logger message #" << counter; + logger->info() << "spdlog logger message #" << counter; } })); } @@ -43,8 +43,8 @@ int main(int argc, char* argv[]) { t.join(); }; - - + + return 0; } diff --git a/bench-comparison/spdlog-bench.cpp b/bench-comparison/spdlog-bench.cpp index 34fa16a8..45ac9cb6 100644 --- a/bench-comparison/spdlog-bench.cpp +++ b/bench-comparison/spdlog-bench.cpp @@ -4,14 +4,14 @@ int main(int argc, char* []) { - int howmany = 1000000; - namespace spd = spdlog; - ///Create a file rotating logger with 5mb size max and 3 rotated files + int howmany = 1000000; + namespace spd = spdlog; + ///Create a file rotating logger with 5mb size max and 3 rotated files auto logger = spd::rotating_logger_mt("file_logger", "logs/spd-sample", 10 *1024 * 1024 , 5); - logger->set_pattern("[%Y-%b-%d %T.%e]: %v"); - for(int i = 0 ; i < howmany; ++i) - logger->info() << "spdlogger message #" << i; + logger->set_pattern("[%Y-%b-%d %T.%e]: %v"); + for(int i = 0 ; i < howmany; ++i) + logger->info() << "spdlogger message #" << i; return 0; } diff --git a/include/spdlog/details/pattern_formatter_impl.h b/include/spdlog/details/pattern_formatter_impl.h index e063583c..9e7ef474 100644 --- a/include/spdlog/details/pattern_formatter_impl.h +++ b/include/spdlog/details/pattern_formatter_impl.h @@ -457,7 +457,7 @@ inline void spdlog::pattern_formatter::handle_flag(char flag) { switch (flag) { - // logger name + // logger name case 'n': _formatters.push_back(std::unique_ptr(new details::name_formatter())); break; From d0678d8a7ec3439ff5be5c85fc978f2da6f798c7 Mon Sep 17 00:00:00 2001 From: gabime Date: Wed, 5 Nov 2014 23:46:15 +0200 Subject: [PATCH 2/3] example typo --- example/example.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/example.cpp b/example/example.cpp index 3e273b8f..12dfe81c 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -29,7 +29,7 @@ #include "spdlog/spdlog.h" -int maina(int, char* []) +int main(int, char* []) { namespace spd = spdlog; From a8c80c406d136571e014f53f8738b5202eb733c7 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Thu, 6 Nov 2014 08:17:53 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3afaba94..e271db45 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Just copy the files to your build tree and use a C++11 compiler ## Benchmarks -Here are some [benchmarks](bench-comparison) comparing spdlog vs boost log(1.56.0) on Ubuntu 64 bits, Intel i7-4770 CPU @ 3.40GHz. +Here are some [benchmarks](bench) comparing spdlog vs boost log(1.56.0) on Ubuntu 64 bits, Intel i7-4770 CPU @ 3.40GHz. The bench writes 1,000,000 log lines to a rotating log file (using shared synchronous logger object):