Commit 350ff13d authored by Kevin M. Godby's avatar Kevin M. Godby

Added g3log and glog benchmarks.

parent 254a6744
...@@ -7,3 +7,6 @@ ...@@ -7,3 +7,6 @@
[submodule "vendor/easyloggingpp"] [submodule "vendor/easyloggingpp"]
path = vendor/easyloggingpp path = vendor/easyloggingpp
url = https://github.com/easylogging/easyloggingpp.git url = https://github.com/easylogging/easyloggingpp.git
[submodule "vendor/g3log"]
path = vendor/g3log
url = https://github.com/KjellKod/g3log.git
...@@ -55,19 +55,13 @@ if(Boost_FOUND) ...@@ -55,19 +55,13 @@ if(Boost_FOUND)
add_benchmark(boost-bench-mt LIBS ${Boost_LIBRARIES} INCLUDES ${Boost_INCLUDE_DIRS} DEFINITIONS ${BOOST_DEFS}) add_benchmark(boost-bench-mt LIBS ${Boost_LIBRARIES} INCLUDES ${Boost_INCLUDE_DIRS} DEFINITIONS ${BOOST_DEFS})
endif() endif()
find_package(glog QUIET)
if(TARGET glog) if(TARGET glog)
add_benchmark(glog-bench LIBS glog) add_benchmark(glog-bench LIBS glog)
add_benchmark(glog-bench-mt LIBS glog) add_benchmark(glog-bench-mt LIBS glog)
endif() endif()
# TODO make g2log find script if(TARGET g3logger)
# TODO use g2log git submodule add_benchmark(g3log-async LIBS g3logger INCLUDES "${g3log_SOURCE_DIR}/src")
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() endif()
if(TARGET easylogging) if(TARGET easylogging)
......
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <thread>
#include <vector>
#include <atomic>
#include <iostream>
#include <chrono>
#include <g3log/logworker.hpp>
#include <g3log/g3log.hpp>
using namespace std;
template<typename T> 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 g3log = g3::LogWorker::createLogWorker();
auto defaultHandler = g3log->addDefaultLogger(argv[0], "logs");
g3::initializeLogging(g3log.get());
std::atomic<int > msg_counter {0};
vector<thread> 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<float> 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;
}
...@@ -7,12 +7,15 @@ ...@@ -7,12 +7,15 @@
add_subdirectory(zf_log) add_subdirectory(zf_log)
#add_subdirectory(glog) add_subdirectory(glog)
add_library(easylogging INTERFACE) add_library(easylogging INTERFACE)
set(SPDLOG_VENDORED_EASYLOGGING_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/easyloggingpp" CACHE INTERNAL "" FORCE) set(SPDLOG_VENDORED_EASYLOGGING_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/easyloggingpp" CACHE INTERNAL "" FORCE)
target_include_directories(easylogging INTERFACE "${SPDLOG_VENDORED_EASYLOGGING_ROOT}/src") target_include_directories(easylogging INTERFACE "${SPDLOG_VENDORED_EASYLOGGING_ROOT}/src")
add_subdirectory(g3log)
#add_library(zflog INTERFACE) #add_library(zflog INTERFACE)
#set(SPDLOG_VENDORED_ZFLOG_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/zf_log" CACHE INTERNAL "" FORCE) #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_include_directories(zflog INTERFACE "${SPDLOG_VENDORED_ZFLOG_ROOT}/zf_log")
......
Subproject commit 6c1698c4f7db6b9e4246ead38051f9866ea3ac06
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment