mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 08:25:43 +08:00
g2log benchmarks
This commit is contained in:
parent
0926a6e2c3
commit
135d0e221c
@ -3,7 +3,7 @@ CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -W
|
||||
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
|
||||
$(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
||||
@ -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)
|
||||
|
||||
|
||||
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:
|
||||
rm -f *.o logs/* spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt glog-bench
|
||||
|
||||
|
49
bench/g2log-bench-mt.cpp
Normal file
49
bench/g2log-bench-mt.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#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;
|
||||
}
|
16
bench/g2log-bench.cpp
Normal file
16
bench/g2log-bench.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#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;
|
||||
}
|
@ -1,28 +0,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
|
||||
echo
|
||||
echo
|
||||
sleep 3
|
||||
|
||||
echo "glog-bench (single thread).."
|
||||
time ./glog-bench
|
||||
echo
|
||||
echo
|
||||
sleep 3
|
||||
|
||||
echo "g2log-bench (single thread).."
|
||||
time ./g2log-bench
|
||||
echo
|
||||
echo
|
||||
sleep 3
|
||||
|
||||
echo "spdlog-bench (single thread)"
|
||||
time ./spdlog-bench
|
||||
echo
|
||||
echo
|
||||
sleep 3
|
||||
|
||||
echo "boost-bench-mt (10 threads, single logger)"..
|
||||
time ./boost-bench-mt
|
||||
echo
|
||||
echo
|
||||
sleep 3
|
||||
|
||||
echo "glog-bench-mt (10 threads, single logger)"..
|
||||
time ./glog-bench-mt
|
||||
echo
|
||||
echo
|
||||
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)"..
|
||||
time ./spdlog-bench-mt
|
||||
echo
|
||||
echo
|
||||
sleep 3
|
||||
|
||||
echo "spdlog-bench-mt-async (10 threads, single logger)"..
|
||||
time ./spdlog-bench-mt-async
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user