From 535e332dc1c85967e09700a46555ae935c7296cd Mon Sep 17 00:00:00 2001 From: gabi Date: Sat, 11 Oct 2014 01:15:26 +0300 Subject: [PATCH] added --- example/bench.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 example/bench.cpp diff --git a/example/bench.cpp b/example/bench.cpp new file mode 100644 index 00000000..043f9bb1 --- /dev/null +++ b/example/bench.cpp @@ -0,0 +1,49 @@ +// example.cpp : Simple logger example +// +#include +#include "c11log/logger.h" +#include "c11log/sinks/async_sink.h" +#include "c11log/sinks/file_sinks.h" +#include "c11log/sinks/stdout_sinks.h" +#include "c11log/sinks/null_sink.h" +#include "utils.h" + +using std::cout; +using std::endl; +using namespace std::chrono; +using namespace c11log; +using namespace utils; + + +int main(int argc, char* argv[]) +{ + + const unsigned int howmany = argc <= 1 ? 10000 : atoi(argv[1]); + + logger cout_logger("example", std::make_shared()); + cout_logger.info() << "Hello logger"; + + //auto nullsink = std::make_shared>(); + auto nullsink = std::make_shared>(); + auto fsink = std::make_shared("log", "txt", 1024 * 1024 * 50, 5, 10); + auto as = std::make_shared(1000); + + + logger my_logger("my_logger", fsink); + + + auto start = system_clock::now(); + for (unsigned int i = 1; i <= howmany; ++i) + my_logger.info() << "Hello logger: msg #" << i; + + + auto delta = system_clock::now() - start; + auto delta_d = duration_cast> (delta).count(); + + cout << "Total:" << format(howmany) << endl; + cout << "Delta:" << format(delta_d) << endl; + cout << "Rate:" << format(howmany / delta_d) << "/sec" << endl; + + return 0; +} +