mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 10:01:33 +08:00
Added g3log and glog benchmarks.
This commit is contained in:
parent
254a6744e4
commit
350ff13d77
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -7,3 +7,6 @@
|
||||
[submodule "vendor/easyloggingpp"]
|
||||
path = vendor/easyloggingpp
|
||||
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)
|
||||
add_benchmark(boost-bench-mt LIBS ${Boost_LIBRARIES} INCLUDES ${Boost_INCLUDE_DIRS} DEFINITIONS ${BOOST_DEFS})
|
||||
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})
|
||||
if(TARGET g3logger)
|
||||
add_benchmark(g3log-async LIBS g3logger INCLUDES "${g3log_SOURCE_DIR}/src")
|
||||
endif()
|
||||
|
||||
if(TARGET easylogging)
|
||||
|
63
bench/g3log-async.cpp
Normal file
63
bench/g3log-async.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
5
vendor/CMakeLists.txt
vendored
5
vendor/CMakeLists.txt
vendored
@ -7,12 +7,15 @@
|
||||
|
||||
add_subdirectory(zf_log)
|
||||
|
||||
#add_subdirectory(glog)
|
||||
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_subdirectory(g3log)
|
||||
|
||||
|
||||
#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")
|
||||
|
1
vendor/g3log
vendored
Submodule
1
vendor/g3log
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 6c1698c4f7db6b9e4246ead38051f9866ea3ac06
|
Loading…
Reference in New Issue
Block a user