mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
file helper
This commit is contained in:
@@ -15,29 +15,37 @@ using namespace utils;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const unsigned int howmany = argc <= 1 ? 600000 : atoi(argv[1]);
|
||||
try {
|
||||
const unsigned int howmany = argc <= 1 ? 500000 : atoi(argv[1]);
|
||||
|
||||
//c11log::set_format("%t");
|
||||
auto console = c11log::create<sinks::stdout_sink_st>("reporter");
|
||||
//console->set_format("[%n %l] %t");
|
||||
console->set_level(c11log::level::INFO);
|
||||
console->info("Starting bench with", howmany, "iterations..");
|
||||
//c11log::set_format("%t");
|
||||
auto console = c11log::create<sinks::stdout_sink_st>("reporter");
|
||||
//console->set_format("[%n %l] %t");
|
||||
console->set_level(c11log::level::INFO);
|
||||
console->info("Starting bench with", howmany, "iterations..");
|
||||
|
||||
//auto bench = c11log::create<sinks::rotating_file_sink_st>("bench", "myrotating", "txt", 1024 * 1024 * 5, 3, 0);
|
||||
auto bench = c11log::create<sinks::daily_file_sink_mt>("bench", "sdfsfddaily", "txt", 0);
|
||||
//auto bench = c11log::create<sinks::simple_file_sink_st>("bench", "simplelog.txt", 1);
|
||||
//auto bench = c11log::create<sinks::null_sink_st>("bench");
|
||||
auto start = system_clock::now();
|
||||
for (unsigned int i = 1; i <= howmany; ++i)
|
||||
{
|
||||
c11log::get("bench")->info("Hello logger: msg number", i);
|
||||
}
|
||||
|
||||
auto delta = system_clock::now() - start;
|
||||
auto delta_d = duration_cast<duration<double>> (delta).count();
|
||||
|
||||
console->info("Total:") << format(howmany);
|
||||
console->info("Delta:") << format(delta_d);
|
||||
console->info("Rate:") << format(howmany / delta_d) << "/sec";
|
||||
|
||||
//auto bench = c11log::create<sinks::rotating_file_sink_st>("bench", "myrotating", "txt", 1024 * 1024 * 5, 3, 100);
|
||||
auto bench = c11log::create<sinks::null_sink_st>("bench");
|
||||
auto start = system_clock::now();
|
||||
for (unsigned int i = 1; i <= howmany; ++i)
|
||||
{
|
||||
c11log::get("bench")->info("Hello logger: msg number", i);
|
||||
}
|
||||
|
||||
auto delta = system_clock::now() - start;
|
||||
auto delta_d = duration_cast<duration<double>> (delta).count();
|
||||
|
||||
console->info("Total:") << format(howmany);
|
||||
console->info("Delta:") << format(delta_d);
|
||||
console->info("Rate:") << format(howmany / delta_d) << "/sec";
|
||||
|
||||
catch (std::exception &ex)
|
||||
{
|
||||
std::cerr << "Exception: " << ex.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ details::fast_oss f(const std::string& what)
|
||||
oss << what;
|
||||
return oss;
|
||||
}
|
||||
int main(int, char* [])
|
||||
int main_(int, char* [])
|
||||
{
|
||||
|
||||
auto foss = f("test2");
|
||||
|
Reference in New Issue
Block a user