spdlog/bench/latency/g3log-crush.cpp

35 lines
834 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:");
2018-03-09 08:26:33 -05:00
if (++counter % 1000000 == 0)
2016-10-01 11:15:21 -04:00
{
std::cout << "Wrote " << counter << " entries" << std::endl;
}
}
}
2018-03-09 08:26:33 -05:00
int main(int argc, char **argv)
2016-10-01 11:15:21 -04:00
{
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;
2018-03-09 08:26:33 -05:00
if (toupper(c) != 'Y')
2016-10-12 16:08:44 -04:00
return 0;
auto worker = g3::LogWorker::createLogWorker();
2018-03-09 08:26:33 -05: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;
}