mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 01:51:38 +08:00
commit
b3988d6e1f
@ -11,7 +11,8 @@ binaries=spdlog-bench spdlog-bench-mt spdlog-async spdlog-null-async \
|
||||
p7-bench p7-bench-mt \
|
||||
log4cpp-bench log4cpp-bench-mt \
|
||||
log4cplus-bench log4cplus-bench-mt \
|
||||
easylogging-bench easylogging-bench-mt
|
||||
easylogging-bench easylogging-bench-mt easylogging-bench-async \
|
||||
plog-bench plog-bench-mt
|
||||
|
||||
all: $(binaries)
|
||||
|
||||
@ -74,9 +75,20 @@ log4cplus-bench-mt: log4cplus-bench-mt.cpp
|
||||
EASYL_FLAGS = -I$(HOME)/easyloggingpp/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)
|
||||
|
||||
easylogging-bench-async: easylogging-bench-async.cpp
|
||||
$(CXX) easylogging-bench-async.cpp -o easylogging-bench-async $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
|
||||
|
||||
PLOG_FLAGS = -I$(HOME)/include
|
||||
plog-bench: plog-bench.cpp
|
||||
$(CXX) plog-bench.cpp -o plog-bench $(CXXFLAGS) $(PLOG_FLAGS) $(CXX_RELEASE_FLAGS)
|
||||
|
||||
plog-bench-mt: plog-bench-mt.cpp
|
||||
$(CXX) plog-bench-mt.cpp -o plog-bench-mt $(CXXFLAGS) $(PLOG_FLAGS) $(CXX_RELEASE_FLAGS)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
|
14
bench/README.md
Normal file
14
bench/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# loggers
|
||||
|
||||
Name | License | Lang. | Year | Platform | Compiler | Dependence | URL
|
||||
--- | --- | --- | --- | --- | --- | --- | ---
|
||||
Pantheios | BSD | C++ | 2017 | Windows, Linux, MacOSX | VC++, GCC(3.2+), Intel, Borland, Comeau, Digital Mars, Metrowerks | STLSoft | http://www.pantheios.org/ <br> http://blog.pantheios.org/ <br> https://github.com/synesissoftware/Pantheios <br> http://www.pantheios.org/performance.html
|
||||
Glog | 3-clause BSD| C++| 2017 | Windows, Linux, MacOSX | VC++, GCC, Clang, intel| Google gflags | https://github.com/google/glog
|
||||
G3log | Public Domain | C++11 | 2018 | Windows, Linux, MacOSX, iPhoneOS | VC++, GCC, Clang, MinGW | None | https://github.com/KjellKod/g3log <br> https://github.com/KjellKod/g3sinks <br> https://kjellkod.wordpress.com/2014/08/16/presenting-g3log-the-next-version-of-the-next-generation-of-loggers/ <br> https://kjellkod.wordpress.com/2015/06/30/the-worlds-fastest-logger-vs-g3log/
|
||||
P7 | LGPL | C++, C, C#, Python | 2017 | Windows, Linux | VC++, GCC, Clang, MinGW | None | http://baical.net/p7.html
|
||||
log4cpp | LGPL | C++ | 2017 | Windows, Linux, MacOSX | VC++, GCC, Sun CC, OpenVMS | Boost | http://log4cpp.sourceforge.net/
|
||||
log4cplus | 2-clause BSD or Apache 2 | C++ | 2017 | Windows, Linux, MacOSX, Android | VC++, GCC, Clang | Boost | https://github.com/log4cplus/log4cplus <br> https://sourceforge.net/p/log4cplus/wiki/Home/
|
||||
Easylogging | MIT | C++11 | 2018 | Windows, Linux, MacOSX, iPhoneOS, Android | VC++, GCC, Clang, Intel, MinGW | None | https://github.com/muflihun/easyloggingpp
|
||||
Spdlog | MIT | C++11 | 2018 | Windows, Linux, MacOSX, iPhoneOS, Android(logcat) | VC++, GCC, Clang, MinGW | None, Headers only library | https://github.com/gabime/spdlog <br> https://github.com/fmtlib/fmt
|
||||
Boost.Log v2 | Boost | C++ | 2016 | Windows, Linux, MacOSX, iPhoneOS, Android | VC++, GCC, Clang | Boost | https://github.com/boostorg/log <br> http://www.boost.org/doc/libs/1_66_0/libs/log/doc/html/index.html
|
||||
plog | MPL 2.0 | C++ | 2017 | Windows, Linux, MacOSX, iPhoneOS, Android | gcc, clang, msvc, mingw, mingw-w64, icc, c++builder | None, Headers only library | https://github.com/SergiusTheBest/plog
|
10
bench/easyl-async.conf
Normal file
10
bench/easyl-async.conf
Normal file
@ -0,0 +1,10 @@
|
||||
* GLOBAL:
|
||||
FORMAT = "[%datetime]: %levshort %thread %msg"
|
||||
FILENAME = ./logs/easylogging-async.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
|
@ -1,5 +1,5 @@
|
||||
* GLOBAL:
|
||||
FORMAT = "[%datetime]: %msg"
|
||||
FORMAT = "[%datetime]: %levshort %thread %msg"
|
||||
FILENAME = ./logs/easylogging-mt.log
|
||||
ENABLED = true
|
||||
TO_FILE = true
|
||||
|
@ -1,5 +1,5 @@
|
||||
* GLOBAL:
|
||||
FORMAT = "[%datetime]: %msg"
|
||||
FORMAT = "[%datetime]: %levshort %msg"
|
||||
FILENAME = ./logs/easylogging.log
|
||||
ENABLED = true
|
||||
TO_FILE = true
|
||||
|
67
bench/easylogging-bench-async.cpp
Normal file
67
bench/easylogging-bench-async.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
//
|
||||
// Copyright(c) 2015 Gabi Melman.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
//
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#define ELPP_THREAD_SAFE
|
||||
#define ELPP_EXPERIMENTAL_ASYNC
|
||||
#include "easylogging++.h"
|
||||
#include "easylogging++.cc"
|
||||
INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using clock = steady_clock;
|
||||
|
||||
int thread_count = 10;
|
||||
if (argc > 1)
|
||||
thread_count = atoi(argv[1]);
|
||||
|
||||
int howmany = 1000000;
|
||||
|
||||
// Load configuration from file
|
||||
el::Configurations conf("easyl-async.conf");
|
||||
el::Loggers::reconfigureLogger("default", conf);
|
||||
|
||||
std::atomic<int> msg_counter{0};
|
||||
vector<thread> threads;
|
||||
|
||||
auto start = clock::now();
|
||||
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();
|
||||
}
|
||||
|
||||
duration<float> delta = clock::now() - start;
|
||||
float deltaf = delta.count();
|
||||
auto rate = howmany / deltaf;
|
||||
|
||||
std::cout << "Total: " << howmany << std::endl;
|
||||
std::cout << "Threads: " << thread_count << std::endl;
|
||||
std::cout << "Delta = " << deltaf << " seconds" << std::endl;
|
||||
std::cout << "Rate = " << rate << "/sec" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
bench/p7-bench
BIN
bench/p7-bench
Binary file not shown.
61
bench/plog-bench-mt.cpp
Normal file
61
bench/plog-bench-mt.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// Copyright(c) 2015 Gabi Melman.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
//
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "plog/Log.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using clock = steady_clock;
|
||||
|
||||
int thread_count = 10;
|
||||
if (argc > 1)
|
||||
thread_count = atoi(argv[1]);
|
||||
|
||||
int howmany = 1000000;
|
||||
|
||||
plog::init(plog::debug, "logs/plog-bench-mt.log");
|
||||
|
||||
std::atomic<int> msg_counter{0};
|
||||
vector<thread> threads;
|
||||
|
||||
auto start = clock::now();
|
||||
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 << "plog message #" << counter << ": This is some text for your pleasure";
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
for (auto &t : threads)
|
||||
{
|
||||
t.join();
|
||||
}
|
||||
|
||||
duration<float> delta = clock::now() - start;
|
||||
float deltaf = delta.count();
|
||||
auto rate = howmany / deltaf;
|
||||
|
||||
std::cout << "Total: " << howmany << std::endl;
|
||||
std::cout << "Threads: " << thread_count << std::endl;
|
||||
std::cout << "Delta = " << deltaf << " seconds" << std::endl;
|
||||
std::cout << "Rate = " << rate << "/sec" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
34
bench/plog-bench.cpp
Normal file
34
bench/plog-bench.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright(c) 2015 Gabi Melman.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
//
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include "plog/Log.h"
|
||||
|
||||
int main(int, char *[])
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using clock = steady_clock;
|
||||
|
||||
int howmany = 1000000;
|
||||
|
||||
plog::init(plog::debug, "logs/plog-bench.log");
|
||||
|
||||
auto start = clock::now();
|
||||
for (int i = 0; i < howmany; ++i)
|
||||
LOG_INFO << "plog message #" << i << ": This is some text for your pleasure";
|
||||
|
||||
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;
|
||||
|
||||
return 0;
|
||||
}
|
@ -3,14 +3,15 @@
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
//
|
||||
|
||||
#include "spdlog/spdlog.h"
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@ -20,42 +21,56 @@ int main(int argc, char *argv[])
|
||||
|
||||
int thread_count = 10;
|
||||
if (argc > 1)
|
||||
thread_count = ::atoi(argv[1]);
|
||||
thread_count = std::atoi(argv[1]);
|
||||
|
||||
int howmany = 1000000;
|
||||
|
||||
spdlog::set_async_mode(1048576);
|
||||
auto logger = spdlog::create<spdlog::sinks::simple_file_sink_mt>("file_logger", "logs/spdlog-bench-async.log", false);
|
||||
logger->set_pattern("[%Y-%b-%d %T.%e]: %f");
|
||||
logger->set_pattern("[%Y-%m-%d %T.%F]: %L %t %v");
|
||||
|
||||
std::atomic<int> msg_counter{0};
|
||||
vector<thread> threads;
|
||||
std::cout << "To stop, press <Enter>" << std::endl;
|
||||
std::atomic<bool> run{true};
|
||||
std::thread stoper(std::thread([&run]() {
|
||||
std::cin.get();
|
||||
run = false;
|
||||
}));
|
||||
|
||||
auto start = clock::now();
|
||||
for (int t = 0; t < thread_count; ++t)
|
||||
while(run)
|
||||
{
|
||||
threads.push_back(std::thread([&]() {
|
||||
while (true)
|
||||
{
|
||||
int counter = ++msg_counter;
|
||||
if (counter > howmany)
|
||||
break;
|
||||
logger->info("spdlog message #{}: This is some text for your pleasure", counter);
|
||||
}
|
||||
}));
|
||||
}
|
||||
std::atomic<int> msg_counter{0};
|
||||
std::vector<std::thread> threads;
|
||||
|
||||
for (auto &t : threads)
|
||||
{
|
||||
t.join();
|
||||
}
|
||||
auto start = clock::now();
|
||||
for (int t = 0; t < thread_count; ++t)
|
||||
{
|
||||
threads.push_back(std::thread([&]() {
|
||||
while (true)
|
||||
{
|
||||
int counter = ++msg_counter;
|
||||
if (counter > howmany)
|
||||
break;
|
||||
logger->info("spdlog message #{}: This is some text for your pleasure", counter);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
duration<float> delta = clock::now() - start;
|
||||
float deltaf = delta.count();
|
||||
auto rate = howmany / deltaf;
|
||||
for (auto &t : threads)
|
||||
{
|
||||
t.join();
|
||||
}
|
||||
|
||||
cout << "Total: " << howmany << std::endl;
|
||||
cout << "Threads: " << thread_count << std::endl;
|
||||
std::cout << "Delta = " << deltaf << " seconds" << std::endl;
|
||||
std::cout << "Rate = " << rate << "/sec" << std::endl;
|
||||
duration<float> delta = clock::now() - start;
|
||||
float deltaf = delta.count();
|
||||
auto rate = howmany / deltaf;
|
||||
|
||||
std::cout << "Total: " << howmany << std::endl;
|
||||
std::cout << "Threads: " << thread_count << std::endl;
|
||||
std::cout << "Delta = " << std::fixed << deltaf << " seconds" << std::endl;
|
||||
std::cout << "Rate = " << std::fixed << rate << "/sec" << std::endl;
|
||||
} //while
|
||||
|
||||
stoper.join();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ int main(int argc, char *argv[])
|
||||
int howmany = 1000000;
|
||||
|
||||
auto logger = spdlog::create<spdlog::sinks::simple_file_sink_mt>("file_logger", "logs/spdlog-bench-mt.log", false);
|
||||
logger->set_pattern("[%Y-%b-%d %T.%f]: %v");
|
||||
logger->set_pattern("[%Y-%m-%d %T.%F]: %L %t %v");
|
||||
|
||||
std::atomic<int> msg_counter{0};
|
||||
std::vector<thread> threads;
|
||||
@ -56,8 +56,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
std::cout << "Total: " << howmany << std::endl;
|
||||
std::cout << "Threads: " << thread_count << std::endl;
|
||||
std::cout << "Delta = " << deltaf << " seconds" << std::endl;
|
||||
std::cout << "Rate = " << rate << "/sec" << std::endl;
|
||||
std::cout << "Delta = " << std::fixed << deltaf << " seconds" << std::endl;
|
||||
std::cout << "Rate = " << std::fixed << rate << "/sec" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ int main(int, char *[])
|
||||
int howmany = 1000000;
|
||||
|
||||
auto logger = spdlog::create<spdlog::sinks::simple_file_sink_st>("file_logger", "logs/spdlog-bench.log", false);
|
||||
logger->set_pattern("[%Y-%b-%d %T.%f]: %v");
|
||||
logger->set_pattern("[%Y-%m-%d %T.%F]: %L %v");
|
||||
|
||||
auto start = clock::now();
|
||||
for (int i = 0; i < howmany; ++i)
|
||||
@ -27,8 +27,8 @@ int main(int, char *[])
|
||||
auto rate = howmany / deltaf;
|
||||
|
||||
std::cout << "Total: " << howmany << std::endl;
|
||||
std::cout << "Delta = " << deltaf << " seconds" << std::endl;
|
||||
std::cout << "Rate = " << rate << "/sec" << std::endl;
|
||||
std::cout << "Delta = " << std::fixed << deltaf << " seconds" << std::endl;
|
||||
std::cout << "Rate = " << std::fixed << rate << "/sec" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user