Update async bench

This commit is contained in:
gabime 2019-08-26 00:53:52 +03:00
parent 6b7f3db28e
commit 25d3c83d3b

View File

@ -48,6 +48,7 @@ int count_lines(const char *filename)
void verify_file(const char *filename, int expected_count) void verify_file(const char *filename, int expected_count)
{ {
spdlog::info("Verifying {} to contain {:n} line..", filename, expected_count);
auto count = count_lines(filename); auto count = count_lines(filename);
if (count != expected_count) if (count != expected_count)
{ {
@ -115,11 +116,7 @@ int main(int argc, char *argv[])
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(filename, true); auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(filename, true);
auto logger = std::make_shared<async_logger>("async_logger", std::move(file_sink), std::move(tp), async_overflow_policy::block); auto logger = std::make_shared<async_logger>("async_logger", std::move(file_sink), std::move(tp), async_overflow_policy::block);
bench_mt(howmany, std::move(logger), threads); bench_mt(howmany, std::move(logger), threads);
verify_file(filename, howmany); verify_file(filename, howmany);
#ifdef SPDLOG_ASYNC_BENCH_VERIFY
verify_file(filename, howmany);
#endif // SPDLOG_ASYNC_BENCH_VERIFY
} }
spdlog::info(""); spdlog::info("");
@ -127,6 +124,7 @@ int main(int argc, char *argv[])
spdlog::info("Queue Overflow Policy: overrun"); spdlog::info("Queue Overflow Policy: overrun");
spdlog::info("*********************************"); spdlog::info("*********************************");
// do same test but discard oldest if queue is full instead of blocking // do same test but discard oldest if queue is full instead of blocking
filename = "logs/basic_async-overrun.log";
for (int i = 0; i < iters; i++) for (int i = 0; i < iters; i++)
{ {
auto tp = std::make_shared<details::thread_pool>(queue_size, 1); auto tp = std::make_shared<details::thread_pool>(queue_size, 1);