-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathprocessor_async.cpp
More file actions
83 lines (65 loc) · 3.88 KB
/
processor_async.cpp
File metadata and controls
83 lines (65 loc) · 3.88 KB
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
//
// Created by Ivan Shynkarenka on 01.08.2016
//
#include "benchmark/cppbenchmark.h"
#include "logging/config.h"
#include "logging/logger.h"
using namespace CppLogging;
const auto settings = CppBenchmark::Settings().ThreadsRange(1, 8, [](int from, int to, int& result) { int r = result; result *= 2; return r; });
class LogConfigFixture
{
protected:
LogConfigFixture()
{
auto async_wait_null_sink = std::make_shared<AsyncWaitProcessor>(std::make_shared<NullLayout>());
async_wait_null_sink->appenders().push_back(std::make_shared<NullAppender>());
Config::ConfigLogger("async-wait-null", async_wait_null_sink);
auto async_wait_free_null_sink = std::make_shared<AsyncWaitFreeProcessor>(std::make_shared<NullLayout>());
async_wait_free_null_sink->appenders().push_back(std::make_shared<NullAppender>());
Config::ConfigLogger("async-wait-free-null", async_wait_free_null_sink);
auto async_wait_binary_sink = std::make_shared<AsyncWaitProcessor>(std::make_shared<BinaryLayout>());
async_wait_binary_sink->appenders().push_back(std::make_shared<NullAppender>());
Config::ConfigLogger("async-wait-binary", async_wait_binary_sink);
auto async_wait_free_binary_sink = std::make_shared<AsyncWaitFreeProcessor>(std::make_shared<BinaryLayout>());
async_wait_free_binary_sink->appenders().push_back(std::make_shared<NullAppender>());
Config::ConfigLogger("async-wait-free-binary", async_wait_free_binary_sink);
auto async_wait_text_sink = std::make_shared<AsyncWaitProcessor>(std::make_shared<TextLayout>());
async_wait_text_sink->appenders().push_back(std::make_shared<NullAppender>());
Config::ConfigLogger("async-wait-text", async_wait_text_sink);
auto async_wait_free_text_sink = std::make_shared<AsyncWaitFreeProcessor>(std::make_shared<TextLayout>());
async_wait_free_text_sink->appenders().push_back(std::make_shared<NullAppender>());
Config::ConfigLogger("async-wait-free-text", async_wait_free_text_sink);
Config::Startup();
}
};
BENCHMARK_THREADS_FIXTURE(LogConfigFixture, "AsyncWaitProcessor-null", settings)
{
thread_local Logger logger = Config::CreateLogger("async-wait-null");
logger.Info("Test {}.{}.{} message", context.metrics().total_operations(), context.metrics().total_operations() / 1000.0, context.name());
}
BENCHMARK_THREADS_FIXTURE(LogConfigFixture, "AsyncWaitFreeProcessor-null", settings)
{
thread_local Logger logger = Config::CreateLogger("async-wait-free-null");
logger.Info("Test {}.{}.{} message", context.metrics().total_operations(), context.metrics().total_operations() / 1000.0, context.name());
}
BENCHMARK_THREADS_FIXTURE(LogConfigFixture, "AsyncWaitProcessor-binary", settings)
{
thread_local Logger logger = Config::CreateLogger("async-wait-binary");
logger.Info("Test {}.{}.{} message", context.metrics().total_operations(), context.metrics().total_operations() / 1000.0, context.name());
}
BENCHMARK_THREADS_FIXTURE(LogConfigFixture, "AsyncWaitFreeProcessor-binary", settings)
{
thread_local Logger logger = Config::CreateLogger("async-wait-free-binary");
logger.Info("Test {}.{}.{} message", context.metrics().total_operations(), context.metrics().total_operations() / 1000.0, context.name());
}
BENCHMARK_THREADS_FIXTURE(LogConfigFixture, "AsyncWaitProcessor-text", settings)
{
thread_local Logger logger = Config::CreateLogger("async-wait-text");
logger.Info("Test {}.{}.{} message", context.metrics().total_operations(), context.metrics().total_operations() / 1000.0, context.name());
}
BENCHMARK_THREADS_FIXTURE(LogConfigFixture, "AsyncWaitFreeProcessor-text", settings)
{
thread_local Logger logger = Config::CreateLogger("async-wait-free-text");
logger.Info("Test {}.{}.{} message", context.metrics().total_operations(), context.metrics().total_operations() / 1000.0, context.name());
}
BENCHMARK_MAIN()