mirror of https://github.com/gabime/spdlog.git
easylogging bench and fix async compare with g2log
parent
37a14f0d22
commit
4250796aea
@ -1,16 +0,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;
|
||||
}
|
@ -1,81 +1,80 @@
|
||||
#~/bin/bash
|
||||
#execute each bench 3 times and print the timing
|
||||
|
||||
exec 2>&1
|
||||
|
||||
#execute and time given exe 3 times
|
||||
bench_exe ()
|
||||
{
|
||||
echo "**************** $1 ****************"
|
||||
for i in {1..3}; do
|
||||
time ./$1 $2;
|
||||
rm -f logs/*
|
||||
sleep 3
|
||||
done;
|
||||
}
|
||||
|
||||
echo "Running benchmakrs (all with 1000,000 writes to the logs folder)"
|
||||
echo
|
||||
echo "boost-bench (single thread).."
|
||||
for i in {1..3}; do time ./boost-bench; done
|
||||
rm -f logs/*
|
||||
echo
|
||||
echo
|
||||
sleep 5
|
||||
#execute given async tests 3 times (timing is already builtin)
|
||||
bench_async ()
|
||||
{
|
||||
echo "**************** $1 ****************"
|
||||
for i in {1..3}; do
|
||||
./$1 $2;
|
||||
rm -f logs/*
|
||||
sleep 3
|
||||
done;
|
||||
}
|
||||
|
||||
echo "glog-bench (single thread).."
|
||||
for i in {1..3}; do time ./glog-bench; done
|
||||
rm -f logs/*
|
||||
echo
|
||||
echo
|
||||
sleep 5
|
||||
|
||||
echo "g2log-bench (single thread).."
|
||||
for i in {1..3}; do time ./g2log-bench; done
|
||||
rm -f logs/*
|
||||
echo
|
||||
echo
|
||||
sleep 5
|
||||
echo "----------------------------------------------------------"
|
||||
echo "Single threaded benchmarks.. (1 thread, 1,000,000 lines)"
|
||||
echo "----------------------------------------------------------"
|
||||
for exe in boost-bench glog-bench easylogging-bench spdlog-bench;
|
||||
do
|
||||
bench_exe $exe 1
|
||||
done;
|
||||
|
||||
echo "spdlog-bench (single thread)"
|
||||
for i in {1..3}; do time ./spdlog-bench; done
|
||||
rm -f logs/*
|
||||
echo
|
||||
echo
|
||||
sleep 5
|
||||
echo "------------------------------------"
|
||||
echo "Multithreaded benchmarks.."
|
||||
echo "------------------------------------"
|
||||
echo "boost-bench-mt (10 threads, single logger)"..
|
||||
for i in {1..3}; do ./boost-bench-mt; done
|
||||
rm -f logs/*
|
||||
echo
|
||||
echo
|
||||
sleep 5
|
||||
echo "----------------------------------------------------------"
|
||||
echo "Multi threaded benchmarks.. (10 threads, 1,000,000 lines)"
|
||||
echo "----------------------------------------------------------"
|
||||
for exe in boost-bench-mt glog-bench-mt easylogging-bench-mt spdlog-bench-mt;
|
||||
do
|
||||
bench_exe $exe 10
|
||||
done;
|
||||
|
||||
echo "glog-bench-mt (10 threads, single logger)"..
|
||||
for i in {1..3}; do time ./glog-bench-mt; done
|
||||
rm -f logs/*
|
||||
echo
|
||||
echo
|
||||
sleep 5
|
||||
echo "----------------------------------------------------------"
|
||||
echo "Multi threaded benchmarks.. (100 threads, 1,000,000 lines)"
|
||||
echo "----------------------------------------------------------"
|
||||
for exe in boost-bench-mt glog-bench-mt easylogging-bench-mt spdlog-bench-mt;
|
||||
do
|
||||
bench_exe $exe 100
|
||||
done;
|
||||
|
||||
|
||||
echo "g2log-bench-mt (10 threads, single logger)"..
|
||||
for i in {1..3}; do time ./g2log-bench-mt; done
|
||||
rm -f logs/*
|
||||
echo
|
||||
echo
|
||||
sleep 5
|
||||
echo "---------------------------------------------------------------"
|
||||
echo "Async, single threaded benchmark.. (1 thread, 1,000,000 lines)"
|
||||
echo "---------------------------------------------------------------"
|
||||
for exe in spdlog-async g2log-async
|
||||
do
|
||||
bench_async $exe 1
|
||||
done;
|
||||
|
||||
echo "spdlog-bench-mt (10 threads, single logger)"..
|
||||
for i in {1..3}; do time ./spdlog-bench-mt; done
|
||||
rm -f logs/*
|
||||
echo
|
||||
echo
|
||||
sleep 5
|
||||
echo "---------------------------------------------------------------"
|
||||
echo "Async, multi threaded benchmark.. (10 threads, 1,000,000 lines)"
|
||||
echo "---------------------------------------------------------------"
|
||||
for exe in spdlog-async g2log-async
|
||||
do
|
||||
bench_async $exe 10
|
||||
done;
|
||||
|
||||
echo "------------------------------------"
|
||||
echo "Async benchmarks.."
|
||||
echo "------------------------------------"
|
||||
|
||||
echo "spdlog-bench-async (single thread)"..
|
||||
for i in {1..3}; do time ./spdlog-bench-async; done
|
||||
rm -f logs/*
|
||||
echo
|
||||
echo
|
||||
sleep 5
|
||||
|
||||
echo "spdlog-bench-mt-async (10 threads, single logger)"..
|
||||
for i in {1..3}; do time ./spdlog-bench-mt-async; done
|
||||
echo "---------------------------------------------------------------"
|
||||
echo "Async, multi threaded benchmark.. (100 threads, 1,000,000 lines)"
|
||||
echo "---------------------------------------------------------------"
|
||||
for exe in spdlog-async g2log-async
|
||||
do
|
||||
bench_async $exe 100
|
||||
done;
|
||||
|
||||
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
|
||||
int main(int, char* [])
|
||||
{
|
||||
int howmany = 1048576;
|
||||
namespace spd = spdlog;
|
||||
spd::set_async_mode(howmany);
|
||||
///Create a file rotating logger with 5mb size max and 3 rotated files
|
||||
auto logger = spd::rotating_logger_mt("file_logger", "logs/spd-sample", 10 *1024 * 1024 , 5);
|
||||
|
||||
logger->set_pattern("[%Y-%b-%d %T.%e]: %v");
|
||||
for(int i = 0 ; i < howmany; ++i)
|
||||
logger->info() << "spdlog message #" << i << ": This is some text for your pleasure";
|
||||
|
||||
|
||||
//because spdlog async logger waits for the back thread logger to finish all messages upon destrcuting,
|
||||
//and we want to measure only the time it took to push those messages to the backthread..
|
||||
abort();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue