mirror of
https://github.com/gabime/spdlog.git
synced 2025-03-29 09:22:41 +08:00
format
This commit is contained in:
parent
5997e5aae7
commit
4b9949de7b
@ -72,18 +72,14 @@ int main(int argc, char *argv[])
|
|||||||
cout << "\n*******************************************************************************\n";
|
cout << "\n*******************************************************************************\n";
|
||||||
cout << "async logging.. " << threads << " threads sharing same logger, " << format(howmany) << " iterations " << endl;
|
cout << "async logging.. " << threads << " threads sharing same logger, " << format(howmany) << " iterations " << endl;
|
||||||
cout << "*******************************************************************************\n";
|
cout << "*******************************************************************************\n";
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
spdlog::init_thread_pool(queue_size, 1);
|
spdlog::init_thread_pool(queue_size, 1);
|
||||||
auto as = spdlog::basic_logger_mt<spdlog::create_async>("as", "logs/basic_async.log", true);
|
auto as = spdlog::basic_logger_mt<spdlog::create_async>("as", "logs/basic_async.log", true);
|
||||||
bench_mt(howmany, as, threads);
|
bench_mt(howmany, as, threads);
|
||||||
spdlog::drop("as");
|
spdlog::drop("as");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (std::exception &ex)
|
catch (std::exception &ex)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ int main(int argc, char *argv[])
|
|||||||
spdlog::init_thread_pool(tp_queue_size, tp_threads);
|
spdlog::init_thread_pool(tp_queue_size, tp_threads);
|
||||||
auto as = spdlog::create_async_logger<null_sink_mt>("async(null-sink)");
|
auto as = spdlog::create_async_logger<null_sink_mt>("async(null-sink)");
|
||||||
total_rate += bench_as(howmany, as, client_threads);
|
total_rate += bench_as(howmany, as, client_threads);
|
||||||
spdlog::drop("async(null-sink)");
|
spdlog::drop("async(null-sink)");
|
||||||
}
|
}
|
||||||
std::cout << endl;
|
std::cout << endl;
|
||||||
std::cout << "Avg rate: " << format(total_rate / iters) << "/sec" << std::endl;
|
std::cout << "Avg rate: " << format(total_rate / iters) << "/sec" << std::endl;
|
||||||
|
@ -113,7 +113,7 @@ void async_example()
|
|||||||
for (int i = 0; i < 100; ++i)
|
for (int i = 0; i < 100; ++i)
|
||||||
{
|
{
|
||||||
async_file->info("Async message #{}", i + 1);
|
async_file->info("Async message #{}", i + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// syslog example (linux/osx/freebsd)
|
// syslog example (linux/osx/freebsd)
|
||||||
|
@ -71,7 +71,6 @@ public:
|
|||||||
pop_cv_.notify_one();
|
pop_cv_.notify_one();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t max_items_;
|
size_t max_items_;
|
||||||
|
@ -138,7 +138,6 @@ public:
|
|||||||
{
|
{
|
||||||
return msg_counter_.load(std::memory_order_relaxed);
|
return msg_counter_.load(std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::atomic<size_t> msg_counter_; // total # of messages processed in this pool
|
std::atomic<size_t> msg_counter_; // total # of messages processed in this pool
|
||||||
|
@ -77,7 +77,6 @@ TEST_CASE("tp->wait_empty() ", "[async]")
|
|||||||
logger->flush();
|
logger->flush();
|
||||||
tp.reset();
|
tp.reset();
|
||||||
|
|
||||||
|
|
||||||
REQUIRE(test_sink->msg_counter() == messages);
|
REQUIRE(test_sink->msg_counter() == messages);
|
||||||
REQUIRE(test_sink->flush_counter() == 1);
|
REQUIRE(test_sink->flush_counter() == 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user