Commit 135d0e22 authored by gabime's avatar gabime

g2log benchmarks

parent 0926a6e2
...@@ -3,7 +3,7 @@ CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -W ...@@ -3,7 +3,7 @@ CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -W
CXX_RELEASE_FLAGS = -O3 -flto CXX_RELEASE_FLAGS = -O3 -flto
all: spdlog-bench spdlog-bench-mt spdlog-bench-async spdlog-bench-mt-async boost-bench boost-bench-mt glog-bench glog-bench-mt all: spdlog-bench spdlog-bench-mt spdlog-bench-async spdlog-bench-mt-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-bench g2log-bench-mt
spdlog-bench: spdlog-bench.cpp spdlog-bench: spdlog-bench.cpp
$(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS) $(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
...@@ -34,6 +34,15 @@ glog-bench-mt: glog-bench-mt.cpp ...@@ -34,6 +34,15 @@ glog-bench-mt: glog-bench-mt.cpp
$(CXX) glog-bench-mt.cpp -o glog-bench-mt $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS) $(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-bench: g2log-bench.cpp
$(CXX) g2log-bench.cpp -o g2log-bench $(CXXFLAGS) $(G2LOG_FLAGS) $(CXX_RELEASE_FLAGS)
g2log-bench-mt: g2log-bench-mt.cpp
$(CXX) g2log-bench-mt.cpp -o g2log-bench-mt $(CXXFLAGS) $(G2LOG_FLAGS) $(CXX_RELEASE_FLAGS)
clean: clean:
rm -f *.o logs/* spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt glog-bench rm -f *.o logs/* spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt glog-bench
......
#include <thread>
#include <vector>
#include <atomic>
#include <iostream>
#include "g2logworker.h"
#include "g2log.h"
using namespace std;
int main(int argc, char* argv[])
{
int thread_count = 10;
if(argc > 1)
thread_count = atoi(argv[1]);
int howmany = 1000000;
g2LogWorker g2log(argv[0], "logs");
g2::initializeLogging(&g2log);
std::atomic<int > msg_counter {0};
vector<thread> threads;
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) << "glog message #" << counter << ": This is some text for your pleasure";
}
}));
}
for(auto &t:threads)
{
t.join();
};
return 0;
}
#include "g2logworker.h"
#include "g2log.h"
int main(int, char* argv[])
{
int howmany = 1000000;
g2LogWorker g2log(argv[0], "logs");
g2::initializeLogging(&g2log);
for(int i = 0 ; i < howmany; ++i)
LOG(INFO) << "g2log message # " << i << ": This is some text for your pleasure";
return 0;
}
@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 ==================================
...@@ -6,31 +6,49 @@ time ./boost-bench ...@@ -6,31 +6,49 @@ time ./boost-bench
echo echo
echo echo
sleep 3 sleep 3
echo "glog-bench (single thread).." echo "glog-bench (single thread).."
time ./glog-bench time ./glog-bench
echo echo
echo echo
sleep 3 sleep 3
echo "g2log-bench (single thread).."
time ./g2log-bench
echo
echo
sleep 3
echo "spdlog-bench (single thread)" echo "spdlog-bench (single thread)"
time ./spdlog-bench time ./spdlog-bench
echo echo
echo echo
sleep 3 sleep 3
echo "boost-bench-mt (10 threads, single logger)".. echo "boost-bench-mt (10 threads, single logger)"..
time ./boost-bench-mt time ./boost-bench-mt
echo echo
echo echo
sleep 3 sleep 3
echo "glog-bench-mt (10 threads, single logger)".. echo "glog-bench-mt (10 threads, single logger)"..
time ./glog-bench-mt time ./glog-bench-mt
echo echo
echo echo
sleep 3 sleep 3
echo "g2log-bench-mt (10 threads, single logger)"..
time ./g2log-bench-mt
echo
echo
sleep 3
echo "spdlog-bench-mt (10 threads, single logger)".. echo "spdlog-bench-mt (10 threads, single logger)"..
time ./spdlog-bench-mt time ./spdlog-bench-mt
echo echo
echo echo
sleep 3 sleep 3
echo "spdlog-bench-mt-async (10 threads, single logger)".. echo "spdlog-bench-mt-async (10 threads, single logger)"..
time ./spdlog-bench-mt-async time ./spdlog-bench-mt-async
......
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