Initial work on benchmarks of other logging systems.
This commit is contained in:
		
							
								
								
									
										9
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					[submodule "vendor/zf_log"]
 | 
				
			||||||
 | 
						path = vendor/zf_log
 | 
				
			||||||
 | 
						url = https://github.com/wonder-mice/zf_log.git
 | 
				
			||||||
 | 
					[submodule "vendor/glog"]
 | 
				
			||||||
 | 
						path = vendor/glog
 | 
				
			||||||
 | 
						url = https://github.com/google/glog.git
 | 
				
			||||||
 | 
					[submodule "vendor/easyloggingpp"]
 | 
				
			||||||
 | 
						path = vendor/easyloggingpp
 | 
				
			||||||
 | 
						url = https://github.com/easylogging/easyloggingpp.git
 | 
				
			||||||
@@ -13,6 +13,7 @@ add_library(spdlog INTERFACE)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF)
 | 
					option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF)
 | 
				
			||||||
option(SPDLOG_BUILD_TESTS "Build tests" OFF)
 | 
					option(SPDLOG_BUILD_TESTS "Build tests" OFF)
 | 
				
			||||||
 | 
					option(SPDLOG_BUILD_BENCHMARKS "Build comparison benchmarks for various logging libraries" OFF)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target_include_directories(
 | 
					target_include_directories(
 | 
				
			||||||
    spdlog
 | 
					    spdlog
 | 
				
			||||||
@@ -32,6 +33,11 @@ if(SPDLOG_BUILD_TESTS)
 | 
				
			|||||||
    add_subdirectory(tests)
 | 
					    add_subdirectory(tests)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(SPDLOG_BUILD_BENCHMARKS)
 | 
				
			||||||
 | 
					    add_subdirectory(vendor)
 | 
				
			||||||
 | 
					    add_subdirectory(bench)
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Install ###
 | 
					### Install ###
 | 
				
			||||||
# * https://github.com/forexample/package-example
 | 
					# * https://github.com/forexample/package-example
 | 
				
			||||||
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
 | 
					set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										78
									
								
								bench/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								bench/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Benchmarks against various logging systems
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Dependencies
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					find_package(Threads)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enable_testing()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Helper function for building benchmark programs
 | 
				
			||||||
 | 
					function(add_benchmark _target)
 | 
				
			||||||
 | 
					    set(options "") # no options
 | 
				
			||||||
 | 
					    set(singleValueArgs "") # no single-value arguments
 | 
				
			||||||
 | 
					    set(multiValueArgs LIBS SOURCES INCLUDES DEFINITIONS) # lists of additional libraries, source files, and include directories
 | 
				
			||||||
 | 
					    cmake_parse_arguments(_benchmark "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    add_executable(${_target} ${_target}.cpp ${_benchmark_SOURCES})
 | 
				
			||||||
 | 
					    target_include_directories(
 | 
				
			||||||
 | 
					        ${_target}
 | 
				
			||||||
 | 
					        PUBLIC
 | 
				
			||||||
 | 
					        ${HEADER_BASE}
 | 
				
			||||||
 | 
					        ${_benchmark_INCLUDES}
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    target_link_libraries(
 | 
				
			||||||
 | 
					        ${_target}
 | 
				
			||||||
 | 
					        ${CMAKE_THREAD_LIBS_INIT}
 | 
				
			||||||
 | 
					        ${_benchmark_LIBS}
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(_benchmark_DEFINITIONS)
 | 
				
			||||||
 | 
					        target_compile_definitions(${_target} ${_benchmark_DEFINITIONS})
 | 
				
			||||||
 | 
					    endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    add_test(NAME test_benchmark_${_target} COMMAND ${_target})
 | 
				
			||||||
 | 
					endfunction()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Benchmark programs
 | 
				
			||||||
 | 
					add_benchmark(spdlog-bench)
 | 
				
			||||||
 | 
					add_benchmark(spdlog-bench-mt)
 | 
				
			||||||
 | 
					add_benchmark(spdlog-async)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(TARGET zf_log)
 | 
				
			||||||
 | 
					    add_benchmark(zf_log-bench LIBS zf_log)
 | 
				
			||||||
 | 
					    add_benchmark(zf_log-bench-mt LIBS zf_log)
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					find_package(Boost QUIET COMPONENTS log)
 | 
				
			||||||
 | 
					if(Boost_FOUND)
 | 
				
			||||||
 | 
					    add_benchmark(boost-bench LIBS ${Boost_LIBRARIES} INCLUDES ${Boost_INCLUDE_DIRS})
 | 
				
			||||||
 | 
					    add_benchmark(boost-bench-mt LIBS ${Boost_LIBRARIES} INCLUDES ${Boost_INCLUDE_DIRS})
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					find_package(glog QUIET)
 | 
				
			||||||
 | 
					if(TARGET glog)
 | 
				
			||||||
 | 
					    add_benchmark(glog-bench LIBS glog)
 | 
				
			||||||
 | 
					    add_benchmark(glog-bench-mt LIBS glog)
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# TODO make g2log find script
 | 
				
			||||||
 | 
					# TODO use g2log git submodule
 | 
				
			||||||
 | 
					find_package(g2log QUIET)
 | 
				
			||||||
 | 
					if(g2log-FOUND)
 | 
				
			||||||
 | 
					    set(G2LOG_LIBRARIES lib_g2logger)
 | 
				
			||||||
 | 
					    set(G2LOG_INCLUDE_DIRS /home/gabi/devel/g2log/g2log/src)
 | 
				
			||||||
 | 
					    add_benchmark(g2log-async LIBS ${G2LOG_LIBRARIES} INCLUDES ${G2LOG_INCLUDE_DIRS})
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(TARGET easylogging)
 | 
				
			||||||
 | 
					    add_benchmark(easylogging-bench LIBS easylogging)
 | 
				
			||||||
 | 
					    add_benchmark(easylogging-bench-mt LIBS easylogging)
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -9,7 +9,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define _ELPP_THREAD_SAFE
 | 
					#define _ELPP_THREAD_SAFE
 | 
				
			||||||
#include "easylogging++.h"
 | 
					#include "easylogging++.h"
 | 
				
			||||||
_INITIALIZE_EASYLOGGINGPP
 | 
					INITIALIZE_EASYLOGGINGPP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace std;
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "easylogging++.h"
 | 
					#include "easylogging++.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
_INITIALIZE_EASYLOGGINGPP
 | 
					INITIALIZE_EASYLOGGINGPP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int, char* [])
 | 
					int main(int, char* [])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@
 | 
				
			|||||||
const char g_path[] = "logs/zf_log.txt";
 | 
					const char g_path[] = "logs/zf_log.txt";
 | 
				
			||||||
int g_fd;
 | 
					int g_fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void output_callback(zf_log_message *msg)
 | 
					static void output_callback(const zf_log_message* msg, void* arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    *msg->p = '\n';
 | 
					    *msg->p = '\n';
 | 
				
			||||||
    write(g_fd, msg->buf, msg->p - msg->buf + 1);
 | 
					    write(g_fd, msg->buf, msg->p - msg->buf + 1);
 | 
				
			||||||
@@ -25,7 +25,7 @@ int main(int argc, char* argv[])
 | 
				
			|||||||
        ZF_LOGE_AUX(ZF_LOG_STDERR, "Failed to open log file: %s", g_path);
 | 
					        ZF_LOGE_AUX(ZF_LOG_STDERR, "Failed to open log file: %s", g_path);
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    zf_log_set_output_callback(ZF_LOG_PUT_STD, output_callback);
 | 
					    ZF_LOG_DEFINE_GLOBAL_OUTPUT = {ZF_LOG_PUT_STD, nullptr, &output_callback};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int thread_count = 10;
 | 
					    int thread_count = 10;
 | 
				
			||||||
    if(argc > 1)
 | 
					    if(argc > 1)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@
 | 
				
			|||||||
const char g_path[] = "logs/zf_log.txt";
 | 
					const char g_path[] = "logs/zf_log.txt";
 | 
				
			||||||
static FILE *g_f;
 | 
					static FILE *g_f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void output_callback(zf_log_message *msg)
 | 
					static void output_callback(const zf_log_message* msg, void* arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    *msg->p = '\n';
 | 
					    *msg->p = '\n';
 | 
				
			||||||
    fwrite(msg->buf, msg->p - msg->buf + 1, 1, g_f);
 | 
					    fwrite(msg->buf, msg->p - msg->buf + 1, 1, g_f);
 | 
				
			||||||
@@ -18,7 +18,7 @@ int main(int, char* [])
 | 
				
			|||||||
        ZF_LOGE_AUX(ZF_LOG_STDERR, "Failed to open log file: %s", g_path);
 | 
					        ZF_LOGE_AUX(ZF_LOG_STDERR, "Failed to open log file: %s", g_path);
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    zf_log_set_output_callback(ZF_LOG_PUT_STD, output_callback);
 | 
					    ZF_LOG_DEFINE_GLOBAL_OUTPUT = {ZF_LOG_PUT_STD, nullptr, &output_callback};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const int howmany = 1000000;
 | 
					    const int howmany = 1000000;
 | 
				
			||||||
    for(int i  = 0 ; i < howmany; ++i)
 | 
					    for(int i  = 0 ; i < howmany; ++i)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										21
									
								
								vendor/CMakeLists.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								vendor/CMakeLists.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# External libraries
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Most of these libraries are used for running comparison benchmarks against
 | 
				
			||||||
 | 
					# other logging libraries.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add_subdirectory(zf_log)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#add_subdirectory(glog)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add_library(easylogging INTERFACE)
 | 
				
			||||||
 | 
					set(SPDLOG_VENDORED_EASYLOGGING_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/easyloggingpp" CACHE INTERNAL "" FORCE)
 | 
				
			||||||
 | 
					target_include_directories(easylogging INTERFACE "${SPDLOG_VENDORED_EASYLOGGING_ROOT}/src")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#add_library(zflog INTERFACE)
 | 
				
			||||||
 | 
					#set(SPDLOG_VENDORED_ZFLOG_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/zf_log" CACHE INTERNAL "" FORCE)
 | 
				
			||||||
 | 
					#target_include_directories(zflog INTERFACE "${SPDLOG_VENDORED_ZFLOG_ROOT}/zf_log")
 | 
				
			||||||
 | 
					##target_compile_definitions(zflog INTERFACE ZFLOG_DEFINITIONS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										1
									
								
								vendor/easyloggingpp
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								vendor/easyloggingpp
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule vendor/easyloggingpp added at f926802dfb
									
								
							
							
								
								
									
										1
									
								
								vendor/glog
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								vendor/glog
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule vendor/glog added at de6149ef8e
									
								
							
							
								
								
									
										1
									
								
								vendor/zf_log
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								vendor/zf_log
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule vendor/zf_log added at 4c15e6704e
									
								
							
		Reference in New Issue
	
	Block a user