From def6fc62f4817985cde269c53805d426d4b2b2ae Mon Sep 17 00:00:00 2001 From: gabime Date: Mon, 24 Nov 2014 23:31:02 +0200 Subject: [PATCH] updated benchmarks --- README.md | 8 ++-- bench/results.txt | 80 +++++++++++++++++++++++++++++++++ bench/run_all.sh | 14 +++++- bench/spdlog-bench-async.cpp | 2 +- bench/spdlog-bench-mt-async.cpp | 2 +- example/bench.cpp | 17 ++++--- 6 files changed, 108 insertions(+), 15 deletions(-) create mode 100644 bench/results.txt diff --git a/README.md b/README.md index c225c3d3..93efed2c 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,12 @@ Just copy the files to your build tree and use a C++11 compiler Below are some [benchmarks](bench) comparing the time needed to log 1,000,000 lines to file under Ubuntu 64 bit, Intel i7-4770 CPU @ 3.40GHz: -|threads|boost log|glog|g2log|spdlog| +|threads|boost log|glog|g2log|spdlog|spdlogasync mode| |-------|:-------:|:-----:|------:|------:| -|1|4.223s|1.084s|3.104s|0.998s| -|10|14.141s|4.204s|3.412s|0.987s| +|1|4.430s|1.115s|3.227s|0.940s|1.574s +|10|13.985s|2.027s|3.476s|3.822s|1.972 + + ## Usage Example diff --git a/bench/results.txt b/bench/results.txt new file mode 100644 index 00000000..8f971e0f --- /dev/null +++ b/bench/results.txt @@ -0,0 +1,80 @@ +Running benchmakrs (all with 1000,000 writes to the logs folder + +boost-bench (single thread).. + +real 0m4.430s +user 0m4.359s +sys 0m0.072s + + +glog-bench (single thread).. + +real 0m1.115s +user 0m0.997s +sys 0m0.117s + + +g2log-bench (single thread).. + +Exiting, log location: logs/g2log-bench.g2log.20141124-232519.log + +real 0m3.277s +user 0m4.189s +sys 0m1.021s + + +spdlog-bench (single thread) + +real 0m0.940s +user 0m0.892s +sys 0m0.048s + + +------------------------------------ +Multithreaded benchmarks.. +------------------------------------ +boost-bench-mt (10 threads, single logger).. + +real 0m13.985s +user 0m35.045s +sys 0m7.196s + + +glog-bench-mt (10 threads, single logger).. + +real 0m2.027s +user 0m5.552s +sys 0m6.223s + + +g2log-bench-mt (10 threads, single logger).. + +Exiting, log location: logs/g2log-bench-mt.g2log.20141124-232551.log + +real 0m3.476s +user 0m7.649s +sys 0m1.619s + + +spdlog-bench-mt (10 threads, single logger).. + +real 0m3.822s +user 0m14.233s +sys 0m6.117s + + +------------------------------------ +Async benchmarks.. +------------------------------------ +spdlog-bench-async (single thread).. + +real 0m1.574s +user 0m2.613s +sys 0m0.405s + + +spdlog-bench-mt-async (10 threads, single logger).. + +real 0m1.972s +user 0m3.965s +sys 0m2.747s diff --git a/bench/run_all.sh b/bench/run_all.sh index 9f76d584..0f62cd33 100755 --- a/bench/run_all.sh +++ b/bench/run_all.sh @@ -24,7 +24,9 @@ time ./spdlog-bench echo echo sleep 3 - +echo "------------------------------------" +echo "Multithreaded benchmarks.." +echo "------------------------------------" echo "boost-bench-mt (10 threads, single logger)".. time ./boost-bench-mt echo @@ -49,6 +51,16 @@ echo echo sleep 3 +echo "------------------------------------" +echo "Async benchmarks.." +echo "------------------------------------" + +echo "spdlog-bench-async (single thread)".. +time ./spdlog-bench-async +echo +echo +sleep 3 + echo "spdlog-bench-mt-async (10 threads, single logger)".. time ./spdlog-bench-mt-async diff --git a/bench/spdlog-bench-async.cpp b/bench/spdlog-bench-async.cpp index a7c7e97c..9054cb6e 100644 --- a/bench/spdlog-bench-async.cpp +++ b/bench/spdlog-bench-async.cpp @@ -6,7 +6,7 @@ int main(int, char* []) { int howmany = 1000000; namespace spd = spdlog; - spd::set_async_mode(howmany, std::chrono::seconds(0)); + spd::set_async_mode(2500, std::chrono::seconds(0)); ///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); diff --git a/bench/spdlog-bench-mt-async.cpp b/bench/spdlog-bench-mt-async.cpp index 98ac371c..17c72a8c 100644 --- a/bench/spdlog-bench-mt-async.cpp +++ b/bench/spdlog-bench-mt-async.cpp @@ -17,7 +17,7 @@ int main(int argc, char* argv[]) int howmany = 1000000; namespace spd = spdlog; - spd::set_async_mode(howmany, std::chrono::seconds(0)); + spd::set_async_mode(2500, std::chrono::seconds(0)); ///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); diff --git a/example/bench.cpp b/example/bench.cpp index fc4a98bf..6810c717 100644 --- a/example/bench.cpp +++ b/example/bench.cpp @@ -52,7 +52,7 @@ int main(int argc, char* argv[]) int howmany = 1000000; int threads = 10; - int flush_interval = 1000; + int flush_interval = 0; int file_size = 30 * 1024 * 1024; int rotating_files = 5; @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) howmany = atoi(argv[1]); if (argc > 2) threads = atoi(argv[2]); - + /* cout << "*******************************************************************************\n"; cout << "Single thread, " << format(howmany) << " iterations, flush every " << flush_interval << " lines"<< endl; cout << "*******************************************************************************\n"; @@ -88,14 +88,13 @@ int main(int argc, char* argv[]) cout << "\n*******************************************************************************\n"; cout << "async logging.. " << threads << " threads sharing same logger, " << format(howmany) << " iterations, flush every " << flush_interval << " lines" << endl; - cout << "*******************************************************************************\n"; - - spdlog::set_async_mode(howmany); - auto rotating_st_async = spdlog::rotating_logger_st("rotating_async", "logs/rotating_async", file_size, rotating_files, flush_interval); - bench(howmany, rotating_st_async); +e cout << "*******************************************************************************\n"; + */ + + spdlog::set_async_mode(2500); auto daily_st_async = spdlog::daily_logger_st("daily_async", "logs/daily_async", flush_interval); - bench(howmany, daily_st_async); - bench(howmany, spdlog::create("null_async")); + bench_mt(howmany, daily_st_async, threads); + spdlog::stop();