diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..89e5b902
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,108 @@
+---
+Language: Cpp
+# BasedOnStyle: LLVM
+AccessModifierOffset: -4
+AlignAfterOpenBracket: DontAlign
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Right
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: true
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Empty
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: false
+ AfterObjCDeclaration: true
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: false
+ SplitEmptyFunction: true
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: false
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: true
+BreakConstructorInitializers: BeforeColon
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit: 140
+CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:
+ - foreach
+ - Q_FOREACH
+ - BOOST_FOREACH
+IncludeCategories:
+ - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
+ Priority: 2
+ - Regex: '^(<|"(gtest|gmock|isl|json)/)'
+ Priority: 3
+ - Regex: '.*'
+ Priority: 1
+IncludeIsMainRegex: '(Test)?$'
+IndentCaseLabels: false
+IndentWidth: 4
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+ReflowComments: true
+SortIncludes: true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp11
+TabWidth: 8
+UseTab: Never
+...
+
diff --git a/.gitignore b/.gitignore
index 2f3cb33d..2b432ca5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
# Auto generated files
+build/*
*.slo
*.lo
*.o
@@ -64,4 +65,7 @@ install_manifest.txt
/tests/logs/*
# idea
-.idea/
\ No newline at end of file
+.idea/
+
+# vscode
+.vscode/
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4fe429d..873979dc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,7 +16,7 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS "-Wall -O3 ${CMAKE_CXX_FLAGS}")
endif()
#---------------------------------------------------------------------------------------
diff --git a/README.md b/README.md
index 73347139..1146b176 100644
--- a/README.md
+++ b/README.md
@@ -120,9 +120,9 @@ int main(int, char*[])
daily_logger->info(123.44);
// Customize msg format for all messages
- spd::set_pattern("*** [%H:%M:%S %z] [thread %t] %v ***");
- rotating_logger->info("This is another message with custom format");
-
+ spd::set_pattern("[%^+++%$] [%H:%M:%S %z] [thread %t] %v");
+ console->info("This an info message with custom format (and custom color range between the '%^' and '%$')");
+ console->error("This an error message with custom format (and custom color range between the '%^' and '%$')");
// Runtime log levels
spd::set_level(spd::level::info); //Set global log level to info
diff --git a/astyle.sh b/astyle.sh
deleted file mode 100755
index a7a90510..00000000
--- a/astyle.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-find . -name "*\.h" -o -name "*\.cpp"|xargs dos2unix
-find . -name "*\.h" -o -name "*\.cpp"|xargs astyle -n -c -A1
-
-
diff --git a/bench/Makefile b/bench/Makefile
index 418a5285..0dd4b19d 100644
--- a/bench/Makefile
+++ b/bench/Makefile
@@ -3,7 +3,16 @@ CXXFLAGS = -march=native -Wall -Wextra -pedantic -std=c++11 -pthread -I../includ
CXX_RELEASE_FLAGS = -O3 -flto -DNDEBUG
-binaries=spdlog-bench spdlog-bench-mt spdlog-async spdlog-null-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-async easylogging-bench easylogging-bench-mt
+# 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
all: $(binaries)
@@ -16,13 +25,10 @@ spdlog-bench-mt: spdlog-bench-mt.cpp
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/usr/include -lboost_log -lboost_log_setup -lboost_filesystem -lboost_system -lboost_thread -lboost_regex -lboost_date_time -lboost_chrono
+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)
@@ -30,33 +36,62 @@ boost-bench: boost-bench.cpp
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_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/gabi/devel/g2log/g2log/src -L/home/gabi/devel/g2log/g2log -llib_g2logger
+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../../easylogging/src/
+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)
-
-.PHONY: clean
+ $(CXX) easylogging-bench-mt.cpp -o easylogging-bench-mt $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
-clean:
- rm -f *.o logs/* $(binaries)
+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)
-rebuild: clean all
+plog-bench-mt: plog-bench-mt.cpp
+ $(CXX) plog-bench-mt.cpp -o plog-bench-mt $(CXXFLAGS) $(PLOG_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
new file mode 100644
index 00000000..aed6ee9b
--- /dev/null
+++ b/bench/README.md
@@ -0,0 +1,14 @@
+# 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/bench/boost-bench-mt.cpp b/bench/boost-bench-mt.cpp
index d845fcec..a076e6e4 100644
--- a/bench/boost-bench-mt.cpp
+++ b/bench/boost-bench-mt.cpp
@@ -3,18 +3,20 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
+#include
+#include
+#include
#include
#include
-#include
#include
-#include
#include
#include
-#include
-#include
-#include
#include
+#include
+#include
+#include
+#include
namespace logging = boost::log;
namespace src = boost::log::sources;
@@ -23,62 +25,62 @@ namespace keywords = boost::log::keywords;
void init()
{
- logging::add_file_log
- (
- keywords::file_name = "logs/boost-sample_%N.log", /*< file name pattern >*/
- keywords::auto_flush = false,
- keywords::format = "[%TimeStamp%]: %Message%"
- );
-
- logging::core::get()->set_filter
- (
- logging::trivial::severity >= logging::trivial::info
- );
-}
-
+ 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[])
+int main(int argc, char *argv[])
{
+ using namespace std::chrono;
+ using clock = steady_clock;
+
int thread_count = 10;
- if(argc > 1)
+ 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;
+ src::severity_logger_mt lg;
- std::atomic msg_counter {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([&]()
- {
+ threads.push_back(std::thread([&]() {
while (true)
{
int counter = ++msg_counter;
- if (counter > howmany) break;
+ if (counter > howmany)
+ break;
BOOST_LOG_SEV(lg, info) << "boost message #" << counter << ": This is some text for your pleasure";
}
}));
}
-
- for(auto &t:threads)
+ 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
index 32c5b692..334fcb93 100644
--- a/bench/boost-bench.cpp
+++ b/bench/boost-bench.cpp
@@ -2,14 +2,18 @@
// 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
+#include
namespace logging = boost::log;
namespace src = boost::log::sources;
@@ -18,30 +22,35 @@ namespace keywords = boost::log::keywords;
void init()
{
- logging::add_file_log
- (
- keywords::file_name = "logs/boost-sample_%N.log", /*< file name pattern >*/
- keywords::auto_flush = false,
- keywords::format = "[%TimeStamp%]: %Message%"
- );
-
- logging::core::get()->set_filter
- (
- logging::trivial::severity >= logging::trivial::info
- );
-}
+ 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 argc, char* [])
+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< severity_level > lg;
- for(int i = 0 ; i < howmany; ++i)
+ 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
new file mode 100644
index 00000000..a6c52050
--- /dev/null
+++ b/bench/easyl-async.conf
@@ -0,0 +1,10 @@
+* 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
new file mode 100644
index 00000000..ceff467c
--- /dev/null
+++ b/bench/easyl-mt.conf
@@ -0,0 +1,10 @@
+* 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
index 3bfb5440..c54f6c83 100644
--- a/bench/easyl.conf
+++ b/bench/easyl.conf
@@ -1,5 +1,5 @@
* GLOBAL:
- FORMAT = "[%datetime]: %msg"
+ FORMAT = "[%datetime]: %levshort %msg"
FILENAME = ./logs/easylogging.log
ENABLED = true
TO_FILE = true
diff --git a/bench/easylogging-bench-async.cpp b/bench/easylogging-bench-async.cpp
new file mode 100644
index 00000000..e9b0dc84
--- /dev/null
+++ b/bench/easylogging-bench-async.cpp
@@ -0,0 +1,67 @@
+//
+// 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
index 98d1ae35..7601d3c0 100644
--- a/bench/easylogging-bench-mt.cpp
+++ b/bench/easylogging-bench-mt.cpp
@@ -3,50 +3,64 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
+#include
+#include
+#include
#include
#include
-#include
-#define _ELPP_THREAD_SAFE
+#define ELPP_THREAD_SAFE
+#include "easylogging++.cc"
#include "easylogging++.h"
-_INITIALIZE_EASYLOGGINGPP
+INITIALIZE_EASYLOGGINGPP
using namespace std;
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
+ using namespace std::chrono;
+ using clock = steady_clock;
int thread_count = 10;
- if(argc > 1)
+ if (argc > 1)
thread_count = atoi(argv[1]);
int howmany = 1000000;
// Load configuration from file
- el::Configurations conf("easyl.conf");
+ el::Configurations conf("easyl-mt.conf");
el::Loggers::reconfigureLogger("default", conf);
- std::atomic msg_counter {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([&]()
- {
+ threads.push_back(std::thread([&]() {
while (true)
{
int counter = ++msg_counter;
- if (counter > howmany) break;
+ if (counter > howmany)
+ break;
LOG(INFO) << "easylog message #" << counter << ": This is some text for your pleasure";
}
}));
}
-
- for(auto &t:threads)
+ 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
index a952cbd5..15c093d8 100644
--- a/bench/easylogging-bench.cpp
+++ b/bench/easylogging-bench.cpp
@@ -3,20 +3,37 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
+#include
+#include
+#include "easylogging++.cc"
#include "easylogging++.h"
+INITIALIZE_EASYLOGGINGPP
-_INITIALIZE_EASYLOGGINGPP
-
-int main(int, char* [])
+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);
- for(int i = 0 ; i < howmany; ++i)
+ 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
index 9f9eb71e..3bbd50f6 100644
--- a/bench/g2log-async.cpp
+++ b/bench/g2log-async.cpp
@@ -3,57 +3,56 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
-#include
-#include
#include
-#include
#include
+#include
+#include
+#include
-#include "g2logworker.h"
#include "g2log.h"
+#include "g2logworker.h"
using namespace std;
-template std::string format(const T& value);
+template
+std::string format(const T &value);
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
using namespace std::chrono;
- using clock=steady_clock;
+ using clock = steady_clock;
int thread_count = 10;
- if(argc > 1)
+ if (argc > 1)
thread_count = atoi(argv[1]);
int howmany = 1000000;
g2LogWorker g2log(argv[0], "logs");
g2::initializeLogging(&g2log);
-
- std::atomic msg_counter {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([&]()
- {
+ threads.push_back(std::thread([&]() {
while (true)
{
int counter = ++msg_counter;
- if (counter > howmany) break;
+ if (counter > howmany)
+ break;
LOG(INFO) << "g2log message #" << counter << ": This is some text for your pleasure";
}
}));
}
-
- for(auto &t:threads)
+ for (auto &t : threads)
{
t.join();
- };
+ }
duration delta = clock::now() - start;
float deltaf = delta.count();
- auto rate = howmany/deltaf;
+ auto rate = howmany / deltaf;
cout << "Total: " << howmany << std::endl;
cout << "Threads: " << thread_count << std::endl;
diff --git a/bench/g3log-async.cpp b/bench/g3log-async.cpp
new file mode 100644
index 00000000..61ed72df
--- /dev/null
+++ b/bench/g3log-async.cpp
@@ -0,0 +1,63 @@
+//
+// 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
index db193aeb..2f0aef19 100644
--- a/bench/glog-bench-mt.cpp
+++ b/bench/glog-bench-mt.cpp
@@ -3,19 +3,23 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
+#include
+#include
+#include
#include
#include
-#include
#include "glog/logging.h"
using namespace std;
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
+ using namespace std::chrono;
+ using clock = steady_clock;
int thread_count = 10;
- if(argc > 1)
+ if (argc > 1)
thread_count = atoi(argv[1]);
int howmany = 1000000;
@@ -24,27 +28,36 @@ int main(int argc, char* argv[])
FLAGS_log_dir = "logs";
google::InitGoogleLogging(argv[0]);
- std::atomic msg_counter {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([&]()
- {
+ threads.push_back(std::thread([&]() {
while (true)
{
int counter = ++msg_counter;
- if (counter > howmany) break;
+ if (counter > howmany)
+ break;
LOG(INFO) << "glog message #" << counter << ": This is some text for your pleasure";
}
}));
}
-
- for(auto &t:threads)
+ 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
index cf7e70a2..7469896c 100644
--- a/bench/glog-bench.cpp
+++ b/bench/glog-bench.cpp
@@ -3,19 +3,32 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
-#include "glog/logging.h"
+#include
+#include
+#include "glog/logging.h"
-int main(int, char* argv[])
+int main(int, char *argv[])
{
- int howmany = 1000000;
+ using namespace std::chrono;
+ using clock = steady_clock;
+ int howmany = 1000000;
FLAGS_logtostderr = 0;
FLAGS_log_dir = "logs";
google::InitGoogleLogging(argv[0]);
- for(int i = 0 ; i < howmany; ++i)
- LOG(INFO) << "glog message # " << i << ": This is some text for your pleasure";
+ 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/g3log-crush.cpp b/bench/latency/g3log-crush.cpp
index 417b014c..5ab85d7a 100644
--- a/bench/latency/g3log-crush.cpp
+++ b/bench/latency/g3log-crush.cpp
@@ -9,29 +9,26 @@ void CrusherLoop()
while (true)
{
LOGF(INFO, "Some text to crush you machine. thread:");
- if(++counter % 1000000 == 0)
+ if (++counter % 1000000 == 0)
{
std::cout << "Wrote " << counter << " entries" << std::endl;
}
}
}
-
-int main(int argc, char** argv)
+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')
+ if (toupper(c) != 'Y')
return 0;
auto worker = g3::LogWorker::createLogWorker();
- auto handle= worker->addDefaultLogger(argv[0], "g3log.txt");
+ 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
index e96e421b..fe067f77 100644
--- a/bench/latency/g3log-latency.cpp
+++ b/bench/latency/g3log-latency.cpp
@@ -1,32 +1,26 @@
-#include
-#include
+#include "utils.h"
+#include
#include
-#include
#include
-#include
+#include
+#include
+#include
+#include
+#include
#include
#include
-#include
-#include
-#include
#include