spdlog/bench/latency/g3log-crush.cpp

38 lines
837 B
C++
Raw Normal View History

2016-10-01 11:15:21 -04:00
#include <iostream>
#include <g3log/g3log.hpp>
#include <g3log/logworker.hpp>
void CrusherLoop()
{
2016-10-12 16:08:44 -04:00
size_t counter = 0;
2016-10-01 11:15:21 -04:00
while (true)
{
2016-10-12 16:08:44 -04:00
LOGF(INFO, "Some text to crush you machine. thread:");
2016-10-01 11:15:21 -04:00
if(++counter % 1000000 == 0)
{
std::cout << "Wrote " << counter << " entries" << std::endl;
}
}
}
int main(int argc, char** argv)
{
std::cout << "WARNING: This test will exaust all your machine memory and will crush it!" << std::endl;
std::cout << "Are you sure you want to continue ? " << std::endl;
char c;
std::cin >> c;
if (toupper( c ) != 'Y')
2016-10-12 16:08:44 -04:00
return 0;
auto worker = g3::LogWorker::createLogWorker();
2016-10-01 11:15:21 -04:00
auto handle= worker->addDefaultLogger(argv[0], "g3log.txt");
2016-10-12 16:08:44 -04:00
g3::initializeLogging(worker.get());
CrusherLoop();
2016-10-01 11:15:21 -04:00
return 0;
}