easylogging-bench.cpp 1 KB
Newer Older
gabime's avatar
gabime committed
1 2 3 4 5
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//

6 7
#include <chrono>
#include <iostream>
gabime's avatar
gabime committed
8

9
#include "easylogging++.cc"
gabime's avatar
gabime committed
10
#include "easylogging++.h"
11
INITIALIZE_EASYLOGGINGPP
gabime's avatar
gabime committed
12

gabime's avatar
gabime committed
13
int main(int, char *[])
gabime's avatar
gabime committed
14
{
15 16 17
    using namespace std::chrono;
    using clock = steady_clock;

gabime's avatar
gabime committed
18
    int howmany = 1000000;
gabime's avatar
gabime committed
19

gabime's avatar
gabime committed
20 21 22
    // Load configuration from file
    el::Configurations conf("easyl.conf");
    el::Loggers::reconfigureLogger("default", conf);
gabime's avatar
gabime committed
23

gabime's avatar
gabime committed
24
    el::Logger *defaultLogger = el::Loggers::getLogger("default");
25 26

    auto start = clock::now();
gabime's avatar
gabime committed
27
    for (int i = 0; i < howmany; ++i)
gabime's avatar
gabime committed
28
        LOG(INFO) << "easylog message #" << i << ": This is some text for your pleasure";
29 30 31 32 33 34 35 36 37

    duration<float> delta = clock::now() - start;
    float deltaf = delta.count();
    auto rate = howmany / deltaf;

    std::cout << "Total: " << howmany << std::endl;
    std::cout << "Delta = " << deltaf << " seconds" << std::endl;
    std::cout << "Rate = " << rate << "/sec" << std::endl;

gabime's avatar
gabime committed
38
    return 0;
gabime's avatar
gabime committed
39
}