From 15d64323025d40fa6a7c3e8b577ae8d59b9d62e6 Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 26 May 2018 17:42:49 +0300 Subject: [PATCH] Fixed bench --- bench/spdlog-async.cpp | 9 +++++---- bench/spdlog-bench-mt.cpp | 1 + bench/spdlog-bench.cpp | 1 + bench/spdlog-null-async.cpp | 8 ++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bench/spdlog-async.cpp b/bench/spdlog-async.cpp index e8b70009..32c9541c 100644 --- a/bench/spdlog-async.cpp +++ b/bench/spdlog-async.cpp @@ -10,7 +10,8 @@ #include #include -#include "spdlog/spdlog.h" +#include "spdlog/async.h" +#include "spdlog/sinks/simple_file_sink.h" using namespace std; @@ -24,9 +25,9 @@ int main(int argc, char *argv[]) thread_count = std::atoi(argv[1]); int howmany = 1000000; - - spdlog::set_async_mode(1048576); - auto logger = spdlog::create("file_logger", "logs/spdlog-bench-async.log", false); + spdlog::init_thread_pool (howmany, 1); + + auto logger = spdlog::create_async_logger("file_logger", "logs/spdlog-bench-async.log", false); logger->set_pattern("[%Y-%m-%d %T.%F]: %L %t %v"); std::cout << "To stop, press " << std::endl; diff --git a/bench/spdlog-bench-mt.cpp b/bench/spdlog-bench-mt.cpp index 62dd9cc7..02ce98f5 100644 --- a/bench/spdlog-bench-mt.cpp +++ b/bench/spdlog-bench-mt.cpp @@ -11,6 +11,7 @@ #include #include "spdlog/spdlog.h" +#include "spdlog/sinks/simple_file_sink.h" using namespace std; diff --git a/bench/spdlog-bench.cpp b/bench/spdlog-bench.cpp index bb8a5ef8..395dc271 100644 --- a/bench/spdlog-bench.cpp +++ b/bench/spdlog-bench.cpp @@ -7,6 +7,7 @@ #include #include "spdlog/spdlog.h" +#include "spdlog/sinks/simple_file_sink.h" int main(int, char *[]) { diff --git a/bench/spdlog-null-async.cpp b/bench/spdlog-null-async.cpp index e9b33c9d..3252ce1a 100644 --- a/bench/spdlog-null-async.cpp +++ b/bench/spdlog-null-async.cpp @@ -9,6 +9,7 @@ #include "spdlog/async_logger.h" #include "spdlog/sinks/null_sink.h" #include "spdlog/spdlog.h" +#include "spdlog/async.h" #include "utils.h" #include #include // EXIT_FAILURE @@ -46,15 +47,14 @@ int main(int argc, char *argv[]) cout << "\n*******************************************************************************\n"; cout << "async logging.. " << threads << " threads sharing same logger, " << format(howmany) << " messages " << endl; cout << "*******************************************************************************\n"; - - spdlog::set_async_mode(queue_size); - + size_t total_rate = 0; for (int i = 0; i < iters; ++i) { + spdlog::init_thread_pool (queue_size, 1); // auto as = spdlog::daily_logger_st("as", "logs/daily_async"); - auto as = spdlog::create("async(null-sink)"); + auto as = spdlog::create_async_logger ("async(null-sink)"); total_rate += bench_as(howmany, as, threads); spdlog::drop("async(null-sink)"); }