diff --git a/bench/Makefile b/bench/Makefile index 0dd4b19d..3a80fd77 100644 --- a/bench/Makefile +++ b/bench/Makefile @@ -3,91 +3,17 @@ CXXFLAGS = -march=native -Wall -Wextra -pedantic -std=c++11 -pthread -I../includ CXX_RELEASE_FLAGS = -O3 -flto -DNDEBUG -# g2log-async -binaries=spdlog-bench spdlog-bench-mt spdlog-async spdlog-null-async \ - boost-bench boost-bench-mt \ - glog-bench glog-bench-mt \ - g3log-async \ - p7-bench p7-bench-mt \ - log4cpp-bench log4cpp-bench-mt \ - log4cplus-bench log4cplus-bench-mt \ - easylogging-bench easylogging-bench-mt easylogging-bench-async \ - plog-bench plog-bench-mt +binaries=bench spdlog-null-async all: $(binaries) -spdlog-bench: spdlog-bench.cpp - $(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS) +bench: bench.cpp + $(CXX) bench.cpp -o bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -spdlog-bench-mt: spdlog-bench-mt.cpp - $(CXX) spdlog-bench-mt.cpp -o spdlog-bench-mt $(CXXFLAGS) $(CXX_RELEASE_FLAGS) - -spdlog-async: spdlog-async.cpp - $(CXX) spdlog-async.cpp -o spdlog-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS) - spdlog-null-async: spdlog-null-async.cpp $(CXX) spdlog-null-async.cpp -o spdlog-null-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS) + -BOOST_FLAGS = -DBOOST_LOG_DYN_LINK -I$(HOME)/include -I/usr/include -L$(HOME)/lib -lboost_log_setup -lboost_log -lboost_filesystem -lboost_system -lboost_thread -lboost_regex -lboost_date_time -lboost_chrono - -boost-bench: boost-bench.cpp - $(CXX) boost-bench.cpp -o boost-bench $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS) - -boost-bench-mt: boost-bench-mt.cpp - $(CXX) boost-bench-mt.cpp -o boost-bench-mt $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS) - -GLOG_FLAGS = -I$(HOME)/include -L$(HOME)/lib -lglog -glog-bench: glog-bench.cpp - $(CXX) glog-bench.cpp -o glog-bench $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS) - -glog-bench-mt: glog-bench-mt.cpp - $(CXX) glog-bench-mt.cpp -o glog-bench-mt $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS) - -G2LOG_FLAGS = -I$(HOME)/include -L$(HOME)/lib -llib_g2logger -g2log-async: g2log-async.cpp - $(CXX) g2log-async.cpp -o g2log-async $(CXXFLAGS) $(G2LOG_FLAGS) $(CXX_RELEASE_FLAGS) - -G3LOG_FLAGS = -I$(HOME)/include -L$(HOME)/lib -lg3logger -g3log-async: g3log-async.cpp - $(CXX) g3log-async.cpp -o g3log-async $(CXXFLAGS) $(G3LOG_FLAGS) $(CXX_RELEASE_FLAGS) - -P7_FLAGS = -I$(HOME)/P7/Headers -I$(HOME)/include -L$(HOME)/lib -lP7 -p7-bench: p7-bench.cpp - $(CXX) p7-bench.cpp -o p7-bench $(CXXFLAGS) $(P7_FLAGS) $(CXX_RELEASE_FLAGS) - -p7-bench-mt: p7-bench-mt.cpp - $(CXX) p7-bench-mt.cpp -o p7-bench-mt $(CXXFLAGS) $(P7_FLAGS) $(CXX_RELEASE_FLAGS) - -LOG4CPP_FLAGS = -I$(HOME)/include -L$(HOME)/lib -llog4cpp -log4cpp-bench: log4cpp-bench.cpp - $(CXX) log4cpp-bench.cpp -o log4cpp-bench $(CXXFLAGS) $(LOG4CPP_FLAGS) $(CXX_RELEASE_FLAGS) - -log4cpp-bench-mt: log4cpp-bench-mt.cpp - $(CXX) log4cpp-bench-mt.cpp -o log4cpp-bench-mt $(CXXFLAGS) $(LOG4CPP_FLAGS) $(CXX_RELEASE_FLAGS) - -LOG4CPLUS_FLAGS = -I$(HOME)/include -L$(HOME)/lib -llog4cplus -log4cplus-bench: log4cplus-bench.cpp - $(CXX) log4cplus-bench.cpp -o log4cplus-bench $(CXXFLAGS) $(LOG4CPLUS_FLAGS) $(CXX_RELEASE_FLAGS) - -log4cplus-bench-mt: log4cplus-bench-mt.cpp - $(CXX) log4cplus-bench-mt.cpp -o log4cplus-bench-mt $(CXXFLAGS) $(LOG4CPLUS_FLAGS) $(CXX_RELEASE_FLAGS) - -EASYL_FLAGS = -I$(HOME)/easyloggingpp/src -easylogging-bench: easylogging-bench.cpp - $(CXX) easylogging-bench.cpp -o easylogging-bench $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS) - -easylogging-bench-mt: easylogging-bench-mt.cpp - $(CXX) easylogging-bench-mt.cpp -o easylogging-bench-mt $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS) - -easylogging-bench-async: easylogging-bench-async.cpp - $(CXX) easylogging-bench-async.cpp -o easylogging-bench-async $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS) - -PLOG_FLAGS = -I$(HOME)/include -plog-bench: plog-bench.cpp - $(CXX) plog-bench.cpp -o plog-bench $(CXXFLAGS) $(PLOG_FLAGS) $(CXX_RELEASE_FLAGS) - -plog-bench-mt: plog-bench-mt.cpp - $(CXX) plog-bench-mt.cpp -o plog-bench-mt $(CXXFLAGS) $(PLOG_FLAGS) $(CXX_RELEASE_FLAGS) .PHONY: clean diff --git a/bench/Makefile.mingw b/bench/Makefile.mingw deleted file mode 100644 index b4357be4..00000000 --- a/bench/Makefile.mingw +++ /dev/null @@ -1,57 +0,0 @@ -CXX ?= g++ -CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -pedantic -std=c++11 -pthread -Wl,--no-as-needed -I../include -CXX_RELEASE_FLAGS = -O3 -flto - - -binaries=spdlog-bench spdlog-bench-mt spdlog-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-async easylogging-bench easylogging-bench-mt - -all: $(binaries) - -spdlog-bench: spdlog-bench.cpp - $(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS) - -spdlog-bench-mt: spdlog-bench-mt.cpp - $(CXX) spdlog-bench-mt.cpp -o spdlog-bench-mt $(CXXFLAGS) $(CXX_RELEASE_FLAGS) - -spdlog-async: spdlog-async.cpp - $(CXX) spdlog-async.cpp -o spdlog-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS) - - -BOOST_FLAGS = -DBOOST_LOG_DYN_LINK -I/home/gabi/devel/boost_1_56_0/ -L/home/gabi/devel/boost_1_56_0/stage/lib -lboost_log -lboost_log_setup -lboost_filesystem -lboost_system -lboost_thread -lboost_regex -lboost_date_time -lboost_chrono - -boost-bench: boost-bench.cpp - $(CXX) boost-bench.cpp -o boost-bench $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS) - -boost-bench-mt: boost-bench-mt.cpp - $(CXX) boost-bench-mt.cpp -o boost-bench-mt $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS) - - -GLOG_FLAGS = -lglog -glog-bench: glog-bench.cpp - $(CXX) glog-bench.cpp -o glog-bench $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS) - -glog-bench-mt: glog-bench-mt.cpp - $(CXX) glog-bench-mt.cpp -o glog-bench-mt $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS) - - -G2LOG_FLAGS = -I/home/gabi/devel/g2log/g2log/src -L/home/gabi/devel/g2log/g2log -llib_g2logger -g2log-async: g2log-async.cpp - $(CXX) g2log-async.cpp -o g2log-async $(CXXFLAGS) $(G2LOG_FLAGS) $(CXX_RELEASE_FLAGS) - - -EASYL_FLAGS = -I../../easylogging/src/ -easylogging-bench: easylogging-bench.cpp - $(CXX) easylogging-bench.cpp -o easylogging-bench $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS) -easylogging-bench-mt: easylogging-bench-mt.cpp - $(CXX) easylogging-bench-mt.cpp -o easylogging-bench-mt $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS) - -.PHONY: clean - -clean: - rm -f *.o logs/* $(binaries) - - -rebuild: clean all - - - diff --git a/bench/README.md b/bench/README.md deleted file mode 100644 index aed6ee9b..00000000 --- a/bench/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# loggers - -Name | License | Lang. | Year | Platform | Compiler | Dependence | URL ---- | --- | --- | --- | --- | --- | --- | --- -Pantheios | BSD | C++ | 2017 | Windows, Linux, MacOSX | VC++, GCC(3.2+), Intel, Borland, Comeau, Digital Mars, Metrowerks | STLSoft | http://www.pantheios.org/
http://blog.pantheios.org/
https://github.com/synesissoftware/Pantheios
http://www.pantheios.org/performance.html -Glog | 3-clause BSD| C++| 2017 | Windows, Linux, MacOSX | VC++, GCC, Clang, intel| Google gflags | https://github.com/google/glog -G3log | Public Domain | C++11 | 2018 | Windows, Linux, MacOSX, iPhoneOS | VC++, GCC, Clang, MinGW | None | https://github.com/KjellKod/g3log
https://github.com/KjellKod/g3sinks
https://kjellkod.wordpress.com/2014/08/16/presenting-g3log-the-next-version-of-the-next-generation-of-loggers/
https://kjellkod.wordpress.com/2015/06/30/the-worlds-fastest-logger-vs-g3log/ -P7 | LGPL | C++, C, C#, Python | 2017 | Windows, Linux | VC++, GCC, Clang, MinGW | None | http://baical.net/p7.html -log4cpp | LGPL | C++ | 2017 | Windows, Linux, MacOSX | VC++, GCC, Sun CC, OpenVMS | Boost | http://log4cpp.sourceforge.net/ -log4cplus | 2-clause BSD or Apache 2 | C++ | 2017 | Windows, Linux, MacOSX, Android | VC++, GCC, Clang | Boost | https://github.com/log4cplus/log4cplus
https://sourceforge.net/p/log4cplus/wiki/Home/ -Easylogging | MIT | C++11 | 2018 | Windows, Linux, MacOSX, iPhoneOS, Android | VC++, GCC, Clang, Intel, MinGW | None | https://github.com/muflihun/easyloggingpp -Spdlog | MIT | C++11 | 2018 | Windows, Linux, MacOSX, iPhoneOS, Android(logcat) | VC++, GCC, Clang, MinGW | None, Headers only library | https://github.com/gabime/spdlog
https://github.com/fmtlib/fmt -Boost.Log v2 | Boost | C++ | 2016 | Windows, Linux, MacOSX, iPhoneOS, Android | VC++, GCC, Clang | Boost | https://github.com/boostorg/log
http://www.boost.org/doc/libs/1_66_0/libs/log/doc/html/index.html -plog | MPL 2.0 | C++ | 2017 | Windows, Linux, MacOSX, iPhoneOS, Android | gcc, clang, msvc, mingw, mingw-w64, icc, c++builder | None, Headers only library | https://github.com/SergiusTheBest/plog diff --git a/example/bench.cpp b/bench/bench.cpp similarity index 95% rename from example/bench.cpp rename to bench/bench.cpp index a4f7ce5b..c06a1c03 100644 --- a/example/bench.cpp +++ b/bench/bench.cpp @@ -12,7 +12,6 @@ #include "spdlog/sinks/rotating_file_sink.h" #include "spdlog/sinks/simple_file_sink.h" #include "spdlog/spdlog.h" - #include "utils.h" #include #include // EXIT_FAILURE @@ -73,7 +72,6 @@ int main(int argc, char *argv[]) cout << "\n*******************************************************************************\n"; cout << "async logging.. " << threads << " threads sharing same logger, " << format(howmany) << " iterations " << endl; cout << "*******************************************************************************\n"; - for (int i = 0; i < 3; ++i) { @@ -83,6 +81,9 @@ int main(int argc, char *argv[]) spdlog::drop("as"); } + + + } catch (std::exception &ex) { @@ -104,7 +105,7 @@ void bench(int howmany, std::shared_ptr log) auto delta = system_clock::now() - start; auto delta_d = duration_cast>(delta).count(); - cout << format(int(howmany / delta_d)) << "/sec" << endl; + cout << "Elapsed: " << delta_d << "\t" << format(int(howmany / delta_d)) << "/sec" << endl; } void bench_mt(int howmany, std::shared_ptr log, int thread_count) @@ -134,5 +135,5 @@ void bench_mt(int howmany, std::shared_ptr log, int thread_count auto delta = system_clock::now() - start; auto delta_d = duration_cast>(delta).count(); - cout << format(int(howmany / delta_d)) << "/sec" << endl; + cout << "Elapsed: " << delta_d << "\t" << format(int(howmany / delta_d)) << "/sec" << endl; } diff --git a/bench/boost-bench-mt.cpp b/bench/boost-bench-mt.cpp deleted file mode 100644 index a076e6e4..00000000 --- a/bench/boost-bench-mt.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace logging = boost::log; -namespace src = boost::log::sources; -namespace sinks = boost::log::sinks; -namespace keywords = boost::log::keywords; - -void init() -{ - logging::add_file_log(keywords::file_name = "logs/boost-bench-mt_%N.log", /*< file name pattern >*/ - keywords::auto_flush = false, keywords::format = "[%TimeStamp%]: %Message%"); - - logging::core::get()->set_filter(logging::trivial::severity >= logging::trivial::info); -} - -using namespace std; - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - 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 lg; - - std::atomic msg_counter{0}; - vector threads; - - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - BOOST_LOG_SEV(lg, info) << "boost message #" << counter << ": This is some text for your pleasure"; - } - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - return 0; -} diff --git a/bench/boost-bench.cpp b/bench/boost-bench.cpp deleted file mode 100644 index 334fcb93..00000000 --- a/bench/boost-bench.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace logging = boost::log; -namespace src = boost::log::sources; -namespace sinks = boost::log::sinks; -namespace keywords = boost::log::keywords; - -void init() -{ - logging::add_file_log(keywords::file_name = "logs/boost-bench_%N.log", /*< file name pattern >*/ - keywords::auto_flush = false, keywords::format = "[%TimeStamp%]: %Message%"); - - logging::core::get()->set_filter(logging::trivial::severity >= logging::trivial::info); -} - -int main(int, char *[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int howmany = 1000000; - init(); - logging::add_common_attributes(); - - using namespace logging::trivial; - src::severity_logger_mt lg; - - auto start = clock::now(); - for (int i = 0; i < howmany; ++i) - BOOST_LOG_SEV(lg, info) << "boost message #" << i << ": This is some text for your pleasure"; - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - return 0; -} diff --git a/bench/easyl-async.conf b/bench/easyl-async.conf deleted file mode 100644 index a6c52050..00000000 --- a/bench/easyl-async.conf +++ /dev/null @@ -1,10 +0,0 @@ -* GLOBAL: - FORMAT = "[%datetime]: %levshort %thread %msg" - FILENAME = ./logs/easylogging-async.log - ENABLED = true - TO_FILE = true - TO_STANDARD_OUTPUT = false - MILLISECONDS_WIDTH = 3 - PERFORMANCE_TRACKING = false - MAX_LOG_FILE_SIZE = 10485760 - Log_Flush_Threshold = 10485760 diff --git a/bench/easyl-mt.conf b/bench/easyl-mt.conf deleted file mode 100644 index ceff467c..00000000 --- a/bench/easyl-mt.conf +++ /dev/null @@ -1,10 +0,0 @@ -* GLOBAL: - FORMAT = "[%datetime]: %levshort %thread %msg" - FILENAME = ./logs/easylogging-mt.log - ENABLED = true - TO_FILE = true - TO_STANDARD_OUTPUT = false - MILLISECONDS_WIDTH = 3 - PERFORMANCE_TRACKING = false - MAX_LOG_FILE_SIZE = 10485760 - Log_Flush_Threshold = 10485760 diff --git a/bench/easyl.conf b/bench/easyl.conf deleted file mode 100644 index c54f6c83..00000000 --- a/bench/easyl.conf +++ /dev/null @@ -1,10 +0,0 @@ -* GLOBAL: - FORMAT = "[%datetime]: %levshort %msg" - FILENAME = ./logs/easylogging.log - ENABLED = true - TO_FILE = true - TO_STANDARD_OUTPUT = false - MILLISECONDS_WIDTH = 3 - PERFORMANCE_TRACKING = false - MAX_LOG_FILE_SIZE = 10485760 - Log_Flush_Threshold = 10485760 diff --git a/bench/easylogging-bench-async.cpp b/bench/easylogging-bench-async.cpp deleted file mode 100644 index e9b0dc84..00000000 --- a/bench/easylogging-bench-async.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include - -#define ELPP_THREAD_SAFE -#define ELPP_EXPERIMENTAL_ASYNC -#include "easylogging++.cc" -#include "easylogging++.h" -INITIALIZE_EASYLOGGINGPP - -using namespace std; - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int thread_count = 10; - if (argc > 1) - thread_count = atoi(argv[1]); - - int howmany = 1000000; - - // Load configuration from file - el::Configurations conf("easyl-async.conf"); - el::Loggers::reconfigureLogger("default", conf); - - std::atomic msg_counter{0}; - vector threads; - - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - LOG(INFO) << "easylog message #" << counter << ": This is some text for your pleasure"; - } - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - return 0; -} diff --git a/bench/easylogging-bench-mt.cpp b/bench/easylogging-bench-mt.cpp deleted file mode 100644 index 7601d3c0..00000000 --- a/bench/easylogging-bench-mt.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include - -#define ELPP_THREAD_SAFE -#include "easylogging++.cc" -#include "easylogging++.h" -INITIALIZE_EASYLOGGINGPP - -using namespace std; - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int thread_count = 10; - if (argc > 1) - thread_count = atoi(argv[1]); - - int howmany = 1000000; - - // Load configuration from file - el::Configurations conf("easyl-mt.conf"); - el::Loggers::reconfigureLogger("default", conf); - - std::atomic msg_counter{0}; - vector threads; - - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - LOG(INFO) << "easylog message #" << counter << ": This is some text for your pleasure"; - } - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - return 0; -} diff --git a/bench/easylogging-bench.cpp b/bench/easylogging-bench.cpp deleted file mode 100644 index 15c093d8..00000000 --- a/bench/easylogging-bench.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include - -#include "easylogging++.cc" -#include "easylogging++.h" -INITIALIZE_EASYLOGGINGPP - -int main(int, char *[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int howmany = 1000000; - - // Load configuration from file - el::Configurations conf("easyl.conf"); - el::Loggers::reconfigureLogger("default", conf); - - el::Logger *defaultLogger = el::Loggers::getLogger("default"); - - auto start = clock::now(); - for (int i = 0; i < howmany; ++i) - LOG(INFO) << "easylog message #" << i << ": This is some text for your pleasure"; - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - return 0; -} diff --git a/bench/g2log-async.cpp b/bench/g2log-async.cpp deleted file mode 100644 index 3bbd50f6..00000000 --- a/bench/g2log-async.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include - -#include "g2log.h" -#include "g2logworker.h" - -using namespace std; -template -std::string format(const T &value); - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - int thread_count = 10; - - if (argc > 1) - thread_count = atoi(argv[1]); - int howmany = 1000000; - - g2LogWorker g2log(argv[0], "logs"); - g2::initializeLogging(&g2log); - - std::atomic msg_counter{0}; - vector threads; - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - LOG(INFO) << "g2log message #" << counter << ": This is some text for your pleasure"; - } - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - cout << "Total: " << howmany << std::endl; - cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; -} diff --git a/bench/g3log-async.cpp b/bench/g3log-async.cpp deleted file mode 100644 index 61ed72df..00000000 --- a/bench/g3log-async.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include - -#include "g3log/g3log.hpp" -#include "g3log/logworker.hpp" - -using namespace std; -template -std::string format(const T &value); - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - int thread_count = 10; - - if (argc > 1) - thread_count = atoi(argv[1]); - - int howmany = 1000000; - - auto worker = g3::LogWorker::createLogWorker(); - auto handle = worker->addDefaultLogger(argv[0], "logs"); - g3::initializeLogging(worker.get()); - - std::atomic msg_counter{0}; - vector threads; - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - LOG(INFO) << "g3log message #" << counter << ": This is some text for your pleasure"; - } - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - cout << "Total: " << howmany << std::endl; - cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; -} diff --git a/bench/glog-bench-mt.cpp b/bench/glog-bench-mt.cpp deleted file mode 100644 index 2f0aef19..00000000 --- a/bench/glog-bench-mt.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include - -#include "glog/logging.h" - -using namespace std; - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int thread_count = 10; - if (argc > 1) - thread_count = atoi(argv[1]); - - int howmany = 1000000; - - FLAGS_logtostderr = 0; - FLAGS_log_dir = "logs"; - google::InitGoogleLogging(argv[0]); - - std::atomic msg_counter{0}; - vector threads; - - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - LOG(INFO) << "glog message #" << counter << ": This is some text for your pleasure"; - } - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - return 0; -} diff --git a/bench/glog-bench.cpp b/bench/glog-bench.cpp deleted file mode 100644 index 7469896c..00000000 --- a/bench/glog-bench.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include - -#include "glog/logging.h" - -int main(int, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int howmany = 1000000; - - FLAGS_logtostderr = 0; - FLAGS_log_dir = "logs"; - google::InitGoogleLogging(argv[0]); - auto start = clock::now(); - for (int i = 0; i < howmany; ++i) - LOG(INFO) << "glog message #" << i << ": This is some text for your pleasure"; - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - return 0; -} diff --git a/bench/latency/Makefile b/bench/latency/Makefile deleted file mode 100644 index 99b479a4..00000000 --- a/bench/latency/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -CXX ?= g++ -CXXFLAGS = -march=native -Wall -std=c++11 -pthread -CXX_RELEASE_FLAGS = -O2 -DNDEBUG - - -binaries=spdlog-latency g3log-latency g3log-crush - -all: $(binaries) - -spdlog-latency: spdlog-latency.cpp - $(CXX) spdlog-latency.cpp -o spdlog-latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../include - - - -g3log-latency: g3log-latency.cpp - $(CXX) g3log-latency.cpp -o g3log-latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../../g3log/src -L. -lg3logger - - -g3log-crush: g3log-crush.cpp - $(CXX) g3log-crush.cpp -o g3log-crush $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../../g3log/src -L. -lg3logger - - -.PHONY: clean - -clean: - rm -f *.o *.log $(binaries) - - -rebuild: clean all - - - diff --git a/bench/latency/compare.sh b/bench/latency/compare.sh deleted file mode 100755 index 0f0e4c97..00000000 --- a/bench/latency/compare.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -echo "running spdlog and g3log tests 10 time with ${1:-10} threads each (total 1,000,000 entries).." -rm -f *.log -for i in {1..10} - -do - echo - sleep 0.5 - ./spdlog-latency ${1:-10} 2>/dev/null || exit - sleep 0.5 - ./g3log-latency ${1:-10} 2>/dev/null || exit - -done diff --git a/bench/latency/g3log-crush.cpp b/bench/latency/g3log-crush.cpp deleted file mode 100644 index 5ab85d7a..00000000 --- a/bench/latency/g3log-crush.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include - -#include -#include - -void CrusherLoop() -{ - size_t counter = 0; - while (true) - { - LOGF(INFO, "Some text to crush you machine. thread:"); - if (++counter % 1000000 == 0) - { - std::cout << "Wrote " << counter << " entries" << std::endl; - } - } -} - -int main(int argc, char **argv) -{ - std::cout << "WARNING: This test will exaust all your machine memory and will crush it!" << std::endl; - std::cout << "Are you sure you want to continue ? " << std::endl; - char c; - std::cin >> c; - if (toupper(c) != 'Y') - return 0; - - auto worker = g3::LogWorker::createLogWorker(); - auto handle = worker->addDefaultLogger(argv[0], "g3log.txt"); - g3::initializeLogging(worker.get()); - CrusherLoop(); - - return 0; -} diff --git a/bench/latency/g3log-latency.cpp b/bench/latency/g3log-latency.cpp deleted file mode 100644 index fe067f77..00000000 --- a/bench/latency/g3log-latency.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "utils.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { -const uint64_t g_iterations = 1000000; - -std::atomic g_counter = {0}; - -void MeasurePeakDuringLogWrites(const size_t id, std::vector &result) -{ - - while (true) - { - const size_t value_now = ++g_counter; - if (value_now > g_iterations) - { - return; - } - - auto start_time = std::chrono::high_resolution_clock::now(); - LOGF(INFO, "Some text to log for thread: %ld", id); - auto stop_time = std::chrono::high_resolution_clock::now(); - uint64_t time_us = std::chrono::duration_cast(stop_time - start_time).count(); - result.push_back(time_us); - } -} - -void PrintResults(const std::map> &threads_result, size_t total_us) -{ - - std::vector all_measurements; - all_measurements.reserve(g_iterations); - for (auto &t_result : threads_result) - { - all_measurements.insert(all_measurements.end(), t_result.second.begin(), t_result.second.end()); - } - - // calc worst latenct - auto worst = *std::max_element(all_measurements.begin(), all_measurements.end()); - - // calc avg - auto total = accumulate(begin(all_measurements), end(all_measurements), 0, std::plus()); - auto avg = double(total) / all_measurements.size(); - - std::cout << "[g3log] worst: " << std::setw(10) << std::right << worst << "\tAvg: " << avg << "\tTotal: " << utils::format(total_us) - << " us" << std::endl; -} -} // namespace - -// The purpose of this test is NOT to see how fast -// each thread can possibly write. It is to see what -// the worst latency is for writing a log entry -// -// In the test 1 million log entries will be written -// an atomic counter is used to give each thread what -// it is to write next. The overhead of atomic -// synchronization between the threads are not counted in the worst case latency -int main(int argc, char **argv) -{ - size_t number_of_threads{0}; - if (argc == 2) - { - number_of_threads = atoi(argv[1]); - } - if (argc != 2 || number_of_threads == 0) - { - std::cerr << "USAGE is: " << argv[0] << " number_threads" << std::endl; - return 1; - } - - std::vector threads(number_of_threads); - std::map> threads_result; - - for (size_t idx = 0; idx < number_of_threads; ++idx) - { - // reserve to 1 million for all the result - // it's a test so let's not care about the wasted space - threads_result[idx].reserve(g_iterations); - } - - const std::string g_path = "./"; - const std::string g_prefix_log_name = "g3log-performance-"; - const std::string g_measurement_dump = g_path + g_prefix_log_name + "_RESULT.txt"; - - auto worker = g3::LogWorker::createLogWorker(); - auto handle = worker->addDefaultLogger(argv[0], "g3log.txt"); - g3::initializeLogging(worker.get()); - - auto start_time_application_total = std::chrono::high_resolution_clock::now(); - for (uint64_t idx = 0; idx < number_of_threads; ++idx) - { - threads[idx] = std::thread(MeasurePeakDuringLogWrites, idx, std::ref(threads_result[idx])); - } - for (size_t idx = 0; idx < number_of_threads; ++idx) - { - threads[idx].join(); - } - auto stop_time_application_total = std::chrono::high_resolution_clock::now(); - - uint64_t total_time_in_us = - std::chrono::duration_cast(stop_time_application_total - start_time_application_total).count(); - PrintResults(threads_result, total_time_in_us); - return 0; -} diff --git a/bench/latency/spdlog-latency.cpp b/bench/latency/spdlog-latency.cpp deleted file mode 100644 index a2200c5d..00000000 --- a/bench/latency/spdlog-latency.cpp +++ /dev/null @@ -1,119 +0,0 @@ - -#include "utils.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "spdlog/spdlog.h" - -namespace spd = spdlog; - -namespace { -const uint64_t g_iterations = 1000000; - -std::atomic g_counter = {0}; - -void MeasurePeakDuringLogWrites(const size_t id, std::vector &result) -{ - auto logger = spd::get("file_logger"); - while (true) - { - const size_t value_now = ++g_counter; - if (value_now > g_iterations) - { - return; - } - - auto start_time = std::chrono::high_resolution_clock::now(); - logger->info("Some text to log for thread: [somemore text...............................] {}", id); - auto stop_time = std::chrono::high_resolution_clock::now(); - uint64_t time_us = std::chrono::duration_cast(stop_time - start_time).count(); - result.push_back(time_us); - } -} - -void PrintResults(const std::map> &threads_result, size_t total_us) -{ - - std::vector all_measurements; - all_measurements.reserve(g_iterations); - for (auto &t_result : threads_result) - { - all_measurements.insert(all_measurements.end(), t_result.second.begin(), t_result.second.end()); - } - - // calc worst latenct - auto worst = *std::max_element(all_measurements.begin(), all_measurements.end()); - - // calc avg - auto total = accumulate(begin(all_measurements), end(all_measurements), 0, std::plus()); - auto avg = double(total) / all_measurements.size(); - - std::cout << "[spdlog] worst: " << std::setw(10) << std::right << worst << "\tAvg: " << avg << "\tTotal: " << utils::format(total_us) - << " us" << std::endl; -} -} // namespace - -// The purpose of this test is NOT to see how fast -// each thread can possibly write. It is to see what -// the worst latency is for writing a log entry -// -// In the test 1 million log entries will be written -// an atomic counter is used to give each thread what -// it is to write next. The overhead of atomic -// synchronization between the threads are not counted in the worst case latency -int main(int argc, char **argv) -{ - size_t number_of_threads{0}; - if (argc == 2) - { - number_of_threads = atoi(argv[1]); - } - if (argc != 2 || number_of_threads == 0) - { - std::cerr << "usage: " << argv[0] << " number_threads" << std::endl; - return 1; - } - - std::vector threads(number_of_threads); - std::map> threads_result; - - for (size_t idx = 0; idx < number_of_threads; ++idx) - { - // reserve to 1 million for all the result - // it's a test so let's not care about the wasted space - threads_result[idx].reserve(g_iterations); - } - - int queue_size = 1048576; // 2 ^ 20 - spdlog::set_async_mode(queue_size); - auto logger = spdlog::create("file_logger", "spdlog.log", true); - - // force flush on every call to compare with g3log - auto s = (spd::sinks::simple_file_sink_mt *)logger->sinks()[0].get(); - s->set_force_flush(true); - - auto start_time_application_total = std::chrono::high_resolution_clock::now(); - for (uint64_t idx = 0; idx < number_of_threads; ++idx) - { - threads[idx] = std::thread(MeasurePeakDuringLogWrites, idx, std::ref(threads_result[idx])); - } - for (size_t idx = 0; idx < number_of_threads; ++idx) - { - threads[idx].join(); - } - auto stop_time_application_total = std::chrono::high_resolution_clock::now(); - - uint64_t total_time_in_us = - std::chrono::duration_cast(stop_time_application_total - start_time_application_total).count(); - - PrintResults(threads_result, total_time_in_us); - return 0; -} diff --git a/bench/latency/utils.h b/bench/latency/utils.h deleted file mode 100644 index 91610128..00000000 --- a/bench/latency/utils.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#pragma once - -#include -#include -#include - -namespace utils { - -template -inline std::string format(const T &value) -{ - static std::locale loc(""); - std::stringstream ss; - ss.imbue(loc); - ss << value; - return ss.str(); -} - -template<> -inline std::string format(const double &value) -{ - static std::locale loc(""); - std::stringstream ss; - ss.imbue(loc); - ss << std::fixed << std::setprecision(1) << value; - return ss.str(); -} - -} // namespace utils diff --git a/bench/log4cplus-bench-mt.cpp b/bench/log4cplus-bench-mt.cpp deleted file mode 100644 index 72e2681c..00000000 --- a/bench/log4cplus-bench-mt.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include -#include - -#include "log4cplus/fileappender.h" -#include "log4cplus/helpers/loglog.h" -#include "log4cplus/helpers/property.h" -#include "log4cplus/layout.h" -#include "log4cplus/logger.h" -#include "log4cplus/loggingmacros.h" -#include "log4cplus/ndc.h" - -using namespace log4cplus; - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int thread_count = 10; - if (argc > 1) - thread_count = std::atoi(argv[1]); - - int howmany = 1000000; - - log4cplus::initialize(); - SharedFileAppenderPtr append(new FileAppender(LOG4CPLUS_TEXT("logs/log4cplus-bench-mt.log"), std::ios_base::trunc, true, true)); - append->setName(LOG4CPLUS_TEXT("File")); - - log4cplus::tstring pattern = LOG4CPLUS_TEXT("%d{%Y-%m-%d %H:%M:%S.%Q}: %p - %m %n"); - append->setLayout(std::auto_ptr(new PatternLayout(pattern))); - append->getloc(); - Logger::getRoot().addAppender(SharedAppenderPtr(append.get())); - - Logger root = Logger::getRoot(); - - std::atomic msg_counter{0}; - std::vector threads; - - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - LOG4CPLUS_INFO(root, "log4cplus message #" << counter << ": This is some text for your pleasure"); - } - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - log4cplus::Logger::shutdown(); - return 0; -} diff --git a/bench/log4cplus-bench.cpp b/bench/log4cplus-bench.cpp deleted file mode 100644 index e738aecd..00000000 --- a/bench/log4cplus-bench.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include - -#include "log4cplus/fileappender.h" -#include "log4cplus/helpers/loglog.h" -#include "log4cplus/helpers/property.h" -#include "log4cplus/layout.h" -#include "log4cplus/logger.h" -#include "log4cplus/loggingmacros.h" -#include "log4cplus/ndc.h" - -using namespace log4cplus; - -int main(int, char *[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int howmany = 1000000; - - log4cplus::initialize(); - SharedFileAppenderPtr append(new FileAppender(LOG4CPLUS_TEXT("logs/log4cplus-bench.log"), std::ios_base::trunc, true, true)); - append->setName(LOG4CPLUS_TEXT("File")); - - log4cplus::tstring pattern = LOG4CPLUS_TEXT("%d{%Y-%m-%d %H:%M:%S.%Q}: %p - %m %n"); - append->setLayout(std::auto_ptr(new PatternLayout(pattern))); - append->getloc(); - Logger::getRoot().addAppender(SharedAppenderPtr(append.get())); - - Logger root = Logger::getRoot(); - - auto start = clock::now(); - for (int i = 0; i < howmany; ++i) - LOG4CPLUS_INFO(root, "log4cplus message #" << i << ": This is some text for your pleasure"); - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - log4cplus::Logger::shutdown(); - return 0; -} diff --git a/bench/log4cpp-bench-mt.cpp b/bench/log4cpp-bench-mt.cpp deleted file mode 100644 index b96b8e1b..00000000 --- a/bench/log4cpp-bench-mt.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include -#include - -#include "log4cpp/Appender.hh" -#include "log4cpp/BasicLayout.hh" -#include "log4cpp/Category.hh" -#include "log4cpp/FileAppender.hh" -#include "log4cpp/Layout.hh" -#include "log4cpp/PatternLayout.hh" -#include "log4cpp/Priority.hh" - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int thread_count = 10; - if (argc > 1) - thread_count = std::atoi(argv[1]); - - int howmany = 1000000; - - log4cpp::Appender *appender = new log4cpp::FileAppender("default", "logs/log4cpp-bench-mt.log"); - log4cpp::PatternLayout *layout = new log4cpp::PatternLayout(); - layout->setConversionPattern("%d{%Y-%m-%d %H:%M:%S.%l}: %p - %m %n"); - appender->setLayout(layout); - - log4cpp::Category &root = log4cpp::Category::getRoot(); - root.addAppender(appender); - root.setPriority(log4cpp::Priority::INFO); - - std::atomic msg_counter{0}; - std::vector threads; - - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - root << log4cpp::Priority::INFO << "log4cpp message #" << counter << ": This is some text for your pleasure"; - } - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - root.shutdown(); - return 0; -} diff --git a/bench/log4cpp-bench.cpp b/bench/log4cpp-bench.cpp deleted file mode 100644 index 75029817..00000000 --- a/bench/log4cpp-bench.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include - -#include "log4cpp/Appender.hh" -#include "log4cpp/BasicLayout.hh" -#include "log4cpp/Category.hh" -#include "log4cpp/FileAppender.hh" -#include "log4cpp/Layout.hh" -#include "log4cpp/PatternLayout.hh" -#include "log4cpp/Priority.hh" - -int main(int, char *[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int howmany = 1000000; - - log4cpp::Appender *appender = new log4cpp::FileAppender("default", "logs/log4cpp-bench.log"); - log4cpp::PatternLayout *layout = new log4cpp::PatternLayout(); - layout->setConversionPattern("%d{%Y-%m-%d %H:%M:%S.%l}: %p - %m %n"); - appender->setLayout(layout); - - log4cpp::Category &root = log4cpp::Category::getRoot(); - root.addAppender(appender); - root.setPriority(log4cpp::Priority::INFO); - - auto start = clock::now(); - for (int i = 0; i < howmany; ++i) - root << log4cpp::Priority::INFO << "log4cpp message #" << i << ": This is some text for your pleasure"; - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - root.shutdown(); - return 0; -} diff --git a/bench/p7-bench-mt.cpp b/bench/p7-bench-mt.cpp deleted file mode 100644 index 996922c9..00000000 --- a/bench/p7-bench-mt.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include -#include -#include - -#include "P7_Trace.h" - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int thread_count = 10; - if (argc > 1) - thread_count = std::atoi(argv[1]); - - int howmany = 1000000; - - IP7_Trace::hModule module = NULL; - - // create P7 client object - std::unique_ptr> client( - P7_Create_Client(TM("/P7.Pool=1024 /P7.Sink=FileTxt /P7.Dir=logs/p7-bench-mt")), [&](IP7_Client *ptr) { - if (ptr) - ptr->Release(); - }); - - if (!client) - { - std::cout << "Can't create IP7_Client" << std::endl; - return 1; - } - - // create P7 trace object 1 - std::unique_ptr> trace( - P7_Create_Trace(client.get(), TM("Trace channel 1")), [&](IP7_Trace *ptr) { - if (ptr) - ptr->Release(); - }); - - if (!trace) - { - std::cout << "Can't create IP7_Trace" << std::endl; - return 1; - } - - trace->Register_Thread(TM("Application"), 0); - trace->Register_Module(TM("Main"), &module); - - std::atomic msg_counter{0}; - std::vector threads; - - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - trace->Register_Thread(TM("Application"), t + 1); - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - trace->P7_INFO(module, TM("p7 message #%d: This is some text for your pleasure"), counter); - } - trace->Register_Thread(TM("Application"), t + 1); - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - trace->Unregister_Thread(0); - - return 0; -} diff --git a/bench/p7-bench.cpp b/bench/p7-bench.cpp deleted file mode 100644 index 25c39b03..00000000 --- a/bench/p7-bench.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include - -#include "P7_Trace.h" - -int main(int, char *[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int howmany = 1000000; - - IP7_Trace::hModule module = NULL; - - // create P7 client object - std::unique_ptr> client( - P7_Create_Client(TM("/P7.Pool=1024 /P7.Sink=FileTxt /P7.Dir=logs/p7-bench")), [&](IP7_Client *ptr) { - if (ptr) - ptr->Release(); - }); - - if (!client) - { - std::cout << "Can't create IP7_Client" << std::endl; - return 1; - } - - // create P7 trace object 1 - std::unique_ptr> trace( - P7_Create_Trace(client.get(), TM("Trace channel 1")), [&](IP7_Trace *ptr) { - if (ptr) - ptr->Release(); - }); - - if (!trace) - { - std::cout << "Can't create IP7_Trace" << std::endl; - return 1; - } - - trace->Register_Thread(TM("Application"), 0); - trace->Register_Module(TM("Main"), &module); - - auto start = clock::now(); - for (int i = 0; i < howmany; ++i) - trace->P7_INFO(module, TM("p7 message #%d: This is some text for your pleasure"), i); - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - trace->Unregister_Thread(0); - - return 0; -} diff --git a/bench/plog-bench-mt.cpp b/bench/plog-bench-mt.cpp deleted file mode 100644 index 5951643f..00000000 --- a/bench/plog-bench-mt.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include - -#include "plog/Log.h" - -using namespace std; - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int thread_count = 10; - if (argc > 1) - thread_count = atoi(argv[1]); - - int howmany = 1000000; - - plog::init(plog::debug, "logs/plog-bench-mt.log"); - - std::atomic msg_counter{0}; - vector threads; - - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - LOG_INFO << "plog message #" << counter << ": This is some text for your pleasure"; - } - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - return 0; -} diff --git a/bench/plog-bench.cpp b/bench/plog-bench.cpp deleted file mode 100644 index 3e017fc7..00000000 --- a/bench/plog-bench.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include - -#include "plog/Log.h" - -int main(int, char *[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int howmany = 1000000; - - plog::init(plog::debug, "logs/plog-bench.log"); - - auto start = clock::now(); - for (int i = 0; i < howmany; ++i) - LOG_INFO << "plog message #" << i << ": This is some text for your pleasure"; - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Delta = " << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << rate << "/sec" << std::endl; - - return 0; -} diff --git a/bench/spdlog-bench-mt.cpp b/bench/spdlog-bench-mt.cpp deleted file mode 100644 index c271519d..00000000 --- a/bench/spdlog-bench-mt.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -// Copyright(c) 2015 Gabi Melman. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) -// - -#include -#include -#include -#include -#include -#include - -#include "spdlog/sinks/simple_file_sink.h" -#include "spdlog/spdlog.h" - -using namespace std; - -int main(int argc, char *argv[]) -{ - using namespace std::chrono; - using clock = steady_clock; - - int thread_count = 10; - if (argc > 1) - thread_count = std::atoi(argv[1]); - - int howmany = 1000000; - - auto logger = spdlog::create("file_logger", "logs/spdlog-bench-mt.log", false); - logger->set_pattern("[%Y-%m-%d %T.%F]: %L %t %v"); - - std::atomic msg_counter{0}; - std::vector threads; - - auto start = clock::now(); - for (int t = 0; t < thread_count; ++t) - { - threads.push_back(std::thread([&]() { - while (true) - { - int counter = ++msg_counter; - if (counter > howmany) - break; - logger->info("spdlog message #{}: This is some text for your pleasure", counter); - } - })); - } - - for (auto &t : threads) - { - t.join(); - } - - duration delta = clock::now() - start; - float deltaf = delta.count(); - auto rate = howmany / deltaf; - - std::cout << "Total: " << howmany << std::endl; - std::cout << "Threads: " << thread_count << std::endl; - std::cout << "Delta = " << std::fixed << deltaf << " seconds" << std::endl; - std::cout << "Rate = " << std::fixed << rate << "/sec" << std::endl; - - return 0; -} diff --git a/bench/spdlog-null-async.cpp b/bench/spdlog-null-async.cpp index 87d99a26..2d041657 100644 --- a/bench/spdlog-null-async.cpp +++ b/bench/spdlog-null-async.cpp @@ -63,13 +63,13 @@ int main(int argc, char *argv[]) cout << "*******************************************************************************\n"; size_t total_rate = 0; - spdlog::init_thread_pool(tp_queue_size, tp_threads); + for (int i = 0; i < iters; ++i) { + spdlog::init_thread_pool(tp_queue_size, tp_threads); auto as = spdlog::create_async_logger("async(null-sink)"); total_rate += bench_as(howmany, as, client_threads); - spdlog::drop("async(null-sink)"); - spdlog::thread_pool()->wait_empty(); + spdlog::drop("async(null-sink)"); } std::cout << endl; std::cout << "Avg rate: " << format(total_rate / iters) << "/sec" << std::endl;