mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-21 03:12:41 +08:00
Report memory consumption in async bench
This commit is contained in:
parent
5743adc467
commit
31c428cece
@ -44,7 +44,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
int howmany = 1000000;
|
||||
int queue_size = howmany + 2;
|
||||
int queue_size = std::min(howmany + 2, 32768);
|
||||
int threads = 10;
|
||||
int iters = 3;
|
||||
|
||||
@ -62,16 +62,25 @@ int main(int argc, char *argv[])
|
||||
if (argc > 2)
|
||||
threads = atoi(argv[2]);
|
||||
if (argc > 3)
|
||||
{
|
||||
queue_size = atoi(argv[3]);
|
||||
if(queue_size > 500000)
|
||||
{
|
||||
spdlog::error("Max queue size allowed: 500,000");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > 4)
|
||||
iters = atoi(argv[4]);
|
||||
|
||||
auto slot_size = sizeof(spdlog::details::async_msg);
|
||||
spdlog::info("-------------------------------------------------");
|
||||
spdlog::info("Messages: {:14n}", howmany);
|
||||
spdlog::info("Threads : {:14n}", threads);
|
||||
spdlog::info("Queue : {:14n}", queue_size);
|
||||
spdlog::info("Iters : {:>14n}", iters);
|
||||
spdlog::info("Messages : {:n}", howmany);
|
||||
spdlog::info("Threads : {:n}", threads);
|
||||
spdlog::info("Queue : {:n} slots", queue_size);
|
||||
spdlog::info("Queue memory : {:n} x {} = {:n} KB ", queue_size, slot_size, (queue_size * slot_size)/1024);
|
||||
spdlog::info("Total iters : {:n}", iters);
|
||||
spdlog::info("-------------------------------------------------");
|
||||
|
||||
const char *filename = "logs/basic_async.log";
|
||||
|
@ -36,7 +36,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
spdlog::default_logger()->set_pattern("[%^%l%$] %v");
|
||||
int howmany = 1000000;
|
||||
int queue_size = howmany + 2;
|
||||
int queue_size = 8192;
|
||||
int threads = 10;
|
||||
size_t file_size = 30 * 1024 * 1024;
|
||||
size_t rotating_files = 5;
|
||||
@ -96,11 +96,16 @@ int main(int argc, char *argv[])
|
||||
bench_mt(howmany, std::move(daily_mt), threads);
|
||||
bench_mt(howmany, spdlog::create<null_sink_mt>("null_mt"), threads);
|
||||
|
||||
int iters = 3;
|
||||
spdlog::info("**************************************************************");
|
||||
spdlog::info("Asyncronous.. {:n} threads sharing same logger, {:n} iterations", threads, howmany);
|
||||
spdlog::info("Asyncronous bench {:n} threads sharing same logger", threads);
|
||||
spdlog::info("Messages: {:n}", howmany);
|
||||
spdlog::info("Queue size: {:n} slots", queue_size);
|
||||
auto slot_size = sizeof(spdlog::details::async_msg);
|
||||
spdlog::info("Total queue memory: {}x{} bytes per slot = {:n} Kb ", queue_size, slot_size, (queue_size * slot_size)/1024);
|
||||
spdlog::info("**************************************************************");
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
for (int i = 0; i < iters; ++i)
|
||||
{
|
||||
spdlog::init_thread_pool(static_cast<size_t>(queue_size), 1);
|
||||
auto as = spdlog::basic_logger_mt<spdlog::async_factory>("async", "logs/basic_async.log", true);
|
||||
|
Loading…
Reference in New Issue
Block a user