cache sprintf of time in default formatter

This commit is contained in:
gabime
2014-03-04 00:08:30 +02:00
parent 344b3d2834
commit 2be33c19fc
4 changed files with 45 additions and 20 deletions

View File

@@ -48,20 +48,26 @@ void testlog(int threads)
int main(int argc, char* argv[])
{
if(argc || argv){};
using namespace std::chrono;
using namespace c11log;
using namespace utils;
using std::cout;
using std::endl;
//auto fsink2 = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, seconds(1));
auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, seconds(1));
auto &my_logger = get_logger("example");
auto null_sink = std::make_shared<sinks::null_sink>();
//auto async = std::make_shared<sinks::async_sink>(1000);
//async->add_sink(fsink);
my_logger.add_sink(null_sink);
auto start = system_clock::now();
const unsigned int howmany = 10000000;
for(unsigned int i = 0; i < howmany ; i++)
my_logger.info() << "Hello logger " << i;
//async->shutdown(seconds(3));
auto delta = system_clock::now() - start;
auto delta_d = duration_cast<duration<double>> (delta);
cout << "Total " << format(howmany) << endl;
@@ -71,7 +77,7 @@ int main(int argc, char* argv[])
return 0;
/*
if(argc !=3) {
std::cerr << "Usage: " << argv[0] << " qsize, threads" << std::endl;
return 0;
@@ -93,5 +99,6 @@ int main(int argc, char* argv[])
testlog(threads);
*/
}