From b0b716fc30bc9ca4fda4da78c85c751ee921afc2 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 12 Nov 2014 13:06:26 +0000 Subject: [PATCH 1/2] Fixup syslog on windows to compile - logger does nothing --- include/spdlog/sinks/syslog_sink.h | 16 ++++++++++++---- include/spdlog/spdlog.h | 2 -- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h index 1d7c28d0..d5a20ecf 100644 --- a/include/spdlog/sinks/syslog_sink.h +++ b/include/spdlog/sinks/syslog_sink.h @@ -24,10 +24,20 @@ #pragma once -#ifdef __linux__ - #include +#ifdef __linux__ #include +#else + inline void syslog(int /*prio*/, const char */*fmt*/, ...) {} // TODO Windows Syslog not supported + #define LOG_EMERG 0 /* system is unusable */ + #define LOG_ALERT 1 /* action must be taken immediately */ + #define LOG_CRIT 2 /* critical conditions */ + #define LOG_ERR 3 /* error conditions */ + #define LOG_WARNING 4 /* warning conditions */ + #define LOG_NOTICE 5 /* normal but significant condition */ + #define LOG_INFO 6 /* informational */ + #define LOG_DEBUG 7 /* debug-level messages */ +#endif #include "./sink.h" #include "../common.h" #include "../details/log_msg.h" @@ -84,5 +94,3 @@ namespace spdlog }; } } - -#endif diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 42bff205..636dbebe 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -69,9 +69,7 @@ std::shared_ptr stderr_logger_st(const std::string& logger_name); // Create a syslog logger -#ifdef __linux__ std::shared_ptr syslog_logger(const std::string& logger_name); -#endif // From b59b900f8e0673fb0eb938076636099a20c3d987 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 12 Nov 2014 13:25:41 +0000 Subject: [PATCH 2/2] Added support for bench in windows/mingw64 --- bench/Makefile.mingw | 30 ++++++++++++++++++++++++++++++ bench/run_all.bat | 28 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 bench/Makefile.mingw create mode 100644 bench/run_all.bat diff --git a/bench/Makefile.mingw b/bench/Makefile.mingw new file mode 100644 index 00000000..d6195a3c --- /dev/null +++ b/bench/Makefile.mingw @@ -0,0 +1,30 @@ +CXX = g++ +CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -Wl,--no-as-needed -I../include +CXX_RELEASE_FLAGS = -O3 -flto + + +all: spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt + +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) + +BOOST_FLAGS = -DBOOST_LOG_DYN_LINK -I$(BOOST_ROOT)/include -L$(BOOST_ROOT)/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) + + +clean: + rm -f *.o logs/*.txt spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt + + +rebuild: clean all + + + diff --git a/bench/run_all.bat b/bench/run_all.bat new file mode 100644 index 00000000..0cfffa28 --- /dev/null +++ b/bench/run_all.bat @@ -0,0 +1,28 @@ +@echo off +echo Running benchmarks (all with 1000,000 writes to the logs folder) +echo ================================== +echo boost-bench (single thread) +echo %time% +.\boost-bench +echo %time% +echo ================================== +choice /n /c y /d y /t 1 >NUL +echo spdlog-bench (single thread) +echo %time% +.\spdlog-bench +echo %time% +echo ================================== +choice /n /c y /d y /t 1 >NUL +echo boost-bench-mt (10 threads, single logger) +echo %time% +.\boost-bench-mt +echo %time% +echo ================================== +choice /n /c y /d y /t 1 >NUL +echo spdlog-bench-mt (10 threads, single logger) +echo %time% +.\spdlog-bench-mt +echo %time% +echo ================================== + +