easylogging bench
This commit is contained in:
		
							parent
							
								
									7674bdb40a
								
							
						
					
					
						commit
						b38a36451d
					
				| @ -3,7 +3,9 @@ CXXFLAGS	= -march=native -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -W | ||||
| CXX_RELEASE_FLAGS = -O3 -flto | ||||
| 
 | ||||
| 
 | ||||
| all:	spdlog-bench spdlog-bench-mt spdlog-bench-async spdlog-bench-mt-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-bench g2log-bench-mt  | ||||
| binaries=spdlog-bench spdlog-bench-mt spdlog-bench-async spdlog-bench-mt-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-bench g2log-bench-mt easylogging-bench easylogging-bench-mt | ||||
| 
 | ||||
| all: $(binaries) | ||||
| 
 | ||||
| spdlog-bench: spdlog-bench.cpp | ||||
| 	$(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS) | ||||
| @ -43,8 +45,17 @@ g2log-bench-mt: g2log-bench-mt.cpp | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| EASYL_FLAGS = -I../../easylogging/src/ | ||||
| easylogging-bench: easylogging-bench.cpp | ||||
| 	$(CXX) easylogging-bench.cpp -o easylogging-bench $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS) | ||||
| easylogging-bench-mt: easylogging-bench-mt.cpp | ||||
| 	$(CXX) easylogging-bench-mt.cpp -o easylogging-bench-mt $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)	 | ||||
| 	 | ||||
| .PHONY: clean | ||||
| 
 | ||||
| clean: | ||||
| 	rm -f *.o logs/* spdlog-bench spdlog-bench-mt spdlog-bench-async spdlog-bench-mt-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-bench g2log-bench-mt | ||||
| 	rm -f *.o logs/* $(binaries) | ||||
| 
 | ||||
| 
 | ||||
| rebuild: clean all | ||||
|  | ||||
							
								
								
									
										10
									
								
								bench/easyl.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								bench/easyl.conf
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| * GLOBAL: | ||||
|     FORMAT                  =   "[%datetime]: %msg" | ||||
|     FILENAME                =   ./logs/easylogging.log | ||||
|     ENABLED                 =   true | ||||
|     TO_FILE                 =   true | ||||
|     TO_STANDARD_OUTPUT      =   false | ||||
|     MILLISECONDS_WIDTH      =   3 | ||||
|     PERFORMANCE_TRACKING    =   false | ||||
|     MAX_LOG_FILE_SIZE       =   10485760 | ||||
|     Log_Flush_Threshold		= 	10485760 | ||||
							
								
								
									
										47
									
								
								bench/easylogging-bench-mt.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								bench/easylogging-bench-mt.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,47 @@ | ||||
| #include <thread> | ||||
| #include <vector> | ||||
| #include <atomic> | ||||
| 
 | ||||
| #define _ELPP_THREAD_SAFE | ||||
| #include "easylogging++.h" | ||||
| _INITIALIZE_EASYLOGGINGPP | ||||
| 
 | ||||
| using namespace std; | ||||
| 
 | ||||
| int main(int argc, char* argv[]) | ||||
| { | ||||
| 
 | ||||
|     int thread_count = 10; | ||||
|     if(argc > 1) | ||||
|         thread_count = atoi(argv[1]); | ||||
| 
 | ||||
|     int howmany = 1000000; | ||||
| 
 | ||||
|    // Load configuration from file
 | ||||
|     el::Configurations conf("easyl.conf"); | ||||
|     el::Loggers::reconfigureLogger("default", conf); | ||||
| 
 | ||||
|     std::atomic<int > msg_counter {0}; | ||||
|     vector<thread> threads; | ||||
| 
 | ||||
|     for (int t = 0; t < thread_count; ++t) | ||||
|     { | ||||
|         threads.push_back(std::thread([&]() | ||||
|         { | ||||
|             while (true) | ||||
|             { | ||||
|                 int counter = ++msg_counter; | ||||
|                 if (counter > howmany) break; | ||||
|                 LOG(INFO) << "easylog message #" << counter << ": This is some text for your pleasure"; | ||||
|             } | ||||
|         })); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     for(auto &t:threads) | ||||
|     { | ||||
|         t.join(); | ||||
|     }; | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
							
								
								
									
										16
									
								
								bench/easylogging-bench.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								bench/easylogging-bench.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| #include "easylogging++.h" | ||||
| 
 | ||||
| _INITIALIZE_EASYLOGGINGPP | ||||
| 
 | ||||
| int main(int, char* []) | ||||
| { | ||||
| 	int howmany = 1000000; | ||||
| 	 | ||||
| 	// Load configuration from file
 | ||||
|     el::Configurations conf("easyl.conf"); | ||||
|     el::Loggers::reconfigureLogger("default", conf); | ||||
| 	 | ||||
|     for(int i  = 0 ; i < howmany; ++i) | ||||
|        LOG(INFO) << "easylog message #" << i << ": This is some text for your pleasure"; | ||||
|    return 0; | ||||
| } | ||||
| @ -1,4 +1,8 @@ | ||||
| #~/bin/bash | ||||
| 
 | ||||
| exec 2>&1 | ||||
| 
 | ||||
| 
 | ||||
| echo "Running benchmakrs (all with 1000,000 writes to the logs folder)" | ||||
| echo | ||||
| echo "boost-bench (single thread).." | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user