-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·96 lines (81 loc) · 3.18 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "Tester/tester.h"
#include "Logger/logger_spdlog.h"
#include "Logger/logger_log4cpp.h"
#include "Logger/logger_log4cxx.h"
#include "Logger/logger_log4cplus.h"
#include "Logger/logger_glog.h"
#include "Logger/logger_g3log.h"
using namespace LOGTEST;
int main()
{
// init loggers
std::cout << "initiating loggers..." << std::endl;
Logger_spdlog &spdlog = Logger_spdlog::instance();
Logger_log4cpp &log4cpp = Logger_log4cpp::instance();
Logger_log4cxx &log4cxx = Logger_log4cxx::instance();
Logger_glog &glog = Logger_glog::instance();
Logger_g3log &g3log = Logger_g3log::instance();
Logger_log4cplus &log4cplus = Logger_log4cplus::instance();
// init tester
std::cout << "initiating tester..." << std::endl << std::endl;
Tester tester;
// 1. performance
int total_logs = 1E6;
useconds_t delay= 1;
std::cout << "1. Running overall performance test..." << std::endl;
int test_cases[4] = { 1, 10, 20, 100 };
for (int i = 0; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i)
{
int threads = test_cases[i];
int logs_per_threads = total_logs / threads;
// print test information
std::cout << "Scenario " << i + 1 << ":" << std::endl;
tester.print_header_overall();
// add loggers here
tester.run_overall_performance_test(spdlog, threads, logs_per_threads);
usleep(delay);
tester.run_overall_performance_test(log4cplus, threads, logs_per_threads);
usleep(delay);
tester.run_overall_performance_test(log4cpp, threads, logs_per_threads);
usleep(delay);
tester.run_overall_performance_test(log4cxx, threads, logs_per_threads);
usleep(delay);
tester.run_overall_performance_test(glog, threads, logs_per_threads);
usleep(delay);
tester.run_overall_performance_test(g3log, threads, logs_per_threads);
usleep(delay);
std::cout << std::endl;
}
// 2. latency
std::cout << "2. Running latency test..." << std::endl;
for (int i = 0; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i)
{
int threads = test_cases[i];
int logs_per_threads = total_logs / threads;
// print test information
std::cout << "Scenario " << i + 1 << ":" << std::endl;
tester.print_header_latency();
// add loggers here
tester.run_latency_test(spdlog, threads, logs_per_threads);
usleep(delay);
tester.run_latency_test(log4cplus, threads, logs_per_threads);
usleep(delay);
tester.run_latency_test(log4cpp, threads, logs_per_threads);
usleep(delay);
tester.run_latency_test(log4cxx, threads, logs_per_threads);
usleep(delay);
tester.run_latency_test(glog, threads, logs_per_threads);
usleep(delay);
tester.run_latency_test(g3log, threads, logs_per_threads);
usleep(delay);
std::cout << std::endl;
}
// 3. thread safety
// std::cout << "3. Running thread safety test..." << std::endl;
// tester.run_thread_safety_test(spdlog);
// tester.run_thread_safety_test(log4cpp);
// tester.run_thread_safety_test(log4cxx);
// tester.run_thread_safety_test(glog);
// tester.run_thread_safety_test(g3log);
return 0;
}