added g3log crush example
This commit is contained in:
		@@ -1,9 +1,9 @@
 | 
				
			|||||||
CXX	?= g++
 | 
					CXX	?= g++
 | 
				
			||||||
CXXFLAGS	= -march=native -Wall -std=c++11 -pthread 
 | 
					CXXFLAGS	= -march=native -Wall -std=c++11 -pthread 
 | 
				
			||||||
CXX_RELEASE_FLAGS = -Ofast -DNDEBUG
 | 
					CXX_RELEASE_FLAGS = -O2 -DNDEBUG
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
binaries=spdlog-latency g3log-latency
 | 
					binaries=spdlog-latency g3log-latency g3log-crush
 | 
				
			||||||
 | 
					
 | 
				
			||||||
all: $(binaries)
 | 
					all: $(binaries)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -16,6 +16,10 @@ g3log-latency: g3log-latency.cpp
 | 
				
			|||||||
	$(CXX) g3log-latency.cpp -o g3log-latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../../g3log/src -L. -lg3logger 
 | 
						$(CXX) g3log-latency.cpp -o g3log-latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../../g3log/src -L. -lg3logger 
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
					g3log-crush: g3log-crush.cpp
 | 
				
			||||||
 | 
						$(CXX) g3log-crush.cpp -o g3log-crush $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -I../../../g3log/src -L. -lg3logger 
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						
 | 
				
			||||||
.PHONY: clean
 | 
					.PHONY: clean
 | 
				
			||||||
 | 
					
 | 
				
			||||||
clean:
 | 
					clean:
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										37
									
								
								bench/latency/g3log-crush.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								bench/latency/g3log-crush.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <g3log/g3log.hpp>
 | 
				
			||||||
 | 
					#include <g3log/logworker.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CrusherLoop()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						size_t counter = 0;
 | 
				
			||||||
 | 
					    while (true)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        LOGF(INFO, "Some text to crush you machine. thread:");        
 | 
				
			||||||
 | 
					        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')
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						auto worker = g3::LogWorker::createLogWorker();
 | 
				
			||||||
 | 
					    auto handle= worker->addDefaultLogger(argv[0], "g3log.txt");
 | 
				
			||||||
 | 
					    g3::initializeLogging(worker.get());		
 | 
				
			||||||
 | 
						CrusherLoop();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1,17 +1,3 @@
 | 
				
			|||||||
//// to compile:   c++ bench.cpp -o bench -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include -O3 -fPIC -Ofast -m64 -march=native
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Alternative:   c++ bench.cpp -o bench -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include -O3  -march=native
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// the test code itself is Public domain @ref: Unlicense.org
 | 
					 | 
				
			||||||
// made by KjellKod, 2015, first published for testing of g3log at github.com/kjellkod/g3log
 | 
					 | 
				
			||||||
// Feel free to share, modify etc with no obligations but also with no guarantees from my part either
 | 
					 | 
				
			||||||
// enjoy - Kjell Hedstrom (aka KjellKod)
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// spdlog follows however another license. See the bottow of this file
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <thread>
 | 
					#include <thread>
 | 
				
			||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
#include <atomic>
 | 
					#include <atomic>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,16 +1,3 @@
 | 
				
			|||||||
//// to compile:   c++ bench.cpp -o bench -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include -O3 -fPIC -Ofast -m64 -march=native
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Alternative:   c++ bench.cpp -o bench -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include -O3  -march=native
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// the test code itself is Public domain @ref: Unlicense.org
 | 
					 | 
				
			||||||
// made by KjellKod, 2015, first published for testing of g3log at github.com/kjellkod/g3log
 | 
					 | 
				
			||||||
// Feel free to share, modify etc with no obligations but also with no guarantees from my part either
 | 
					 | 
				
			||||||
// enjoy - Kjell Hedstrom (aka KjellKod)
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// spdlog follows however another license. See the bottow of this file
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <thread>
 | 
					#include <thread>
 | 
				
			||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user