vy commented on code in PR #1639:
URL: https://github.com/apache/logging-log4j2/pull/1639#discussion_r1278885180
##########
log4j-perf/src/main/java/org/apache/logging/log4j/message/ParameterFormatterBenchmark.java:
##########
@@ -51,135 +46,83 @@ public static class ThreadState {
char[] copy = new char[4096];
}
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency3ParamsV3(final ThreadState state) {
- state.buffer.setLength(0);
- final String STR = "p1={}, p2={}, p3={}";
- final int length = STR.length();
- STR.getChars(0, length, state.copy, 0);
- final int count =
ParameterFormatter.countArgumentPlaceholders3(state.copy, length,
state.indices);
- ParameterFormatter.formatMessage3(state.buffer, state.copy, length,
ARGS, count, state.indices);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency5ParamsV3(final ThreadState state) {
- state.buffer.setLength(0);
- final String STR = "p1={}, p2={}, p3={}, p4={}, p5={}";
- final int length = STR.length();
- STR.getChars(0, length, state.copy, 0);
- final int count =
ParameterFormatter.countArgumentPlaceholders3(state.copy, length,
state.indices);
- ParameterFormatter.formatMessage3(state.buffer, state.copy, length,
ARGS, count, state.indices);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency7ParamsV3(final ThreadState state) {
- state.buffer.setLength(0);
- final String STR = "p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={}";
- final int length = STR.length();
- STR.getChars(0, length, state.copy, 0);
- final int count =
ParameterFormatter.countArgumentPlaceholders3(state.copy, length,
state.indices);
- ParameterFormatter.formatMessage3(state.buffer, state.copy, length,
ARGS, count, state.indices);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency9ParamsV3(final ThreadState state) {
- state.buffer.setLength(0);
- final String STR = "p1={}, p2={}, p3={}, p4={}, p5={}, p6={}, p7={},
p8={}, p9={}";
- final int length = STR.length();
- STR.getChars(0, length, state.copy, 0);
- final int count =
ParameterFormatter.countArgumentPlaceholders3(state.copy, length,
state.indices);
- ParameterFormatter.formatMessage3(state.buffer, state.copy, length,
ARGS, count, state.indices);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency3ParamsV2(final ThreadState state) {
- state.buffer.setLength(0);
- final int count =
ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}",
state.indices);
- ParameterFormatter.formatMessage2(state.buffer, "p1={}, p2={}, p3={}",
ARGS, count, state.indices);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency5ParamsV2(final ThreadState state) {
- state.buffer.setLength(0);
- final int count =
ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}, p4={},
p5={}", state.indices);
- ParameterFormatter.formatMessage2(state.buffer, "p1={}, p2={}, p3={},
p4={}, p5={}", ARGS, count, state.indices);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency7ParamsV2(final ThreadState state) {
- state.buffer.setLength(0);
- final int count =
ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}, p4={},
p5={}, p6={}, p7={}", state.indices);
- ParameterFormatter.formatMessage2(state.buffer, "p1={}, p2={}, p3={},
p4={}, p5={}, p6={}, p7={}", ARGS, count, state.indices);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency9ParamsV2(final ThreadState state) {
- state.buffer.setLength(0);
- final int count =
ParameterFormatter.countArgumentPlaceholders2("p1={}, p2={}, p3={}, p4={},
p5={}, p6={}, p7={}, p8={}, p9={}", state.indices);
- ParameterFormatter.formatMessage2(state.buffer, "p1={}, p2={}, p3={},
p4={}, p5={}, p6={}, p7={}, p8={}, p9={}", ARGS, count, state.indices);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency3Params(final ThreadState state) {
- state.buffer.setLength(0);
- final int count = ParameterFormatter.countArgumentPlaceholders("p1={},
p2={}, p3={}");
- ParameterFormatter.formatMessage(state.buffer, "p1={}, p2={}, p3={}",
ARGS, count);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency5Params(final ThreadState state) {
- state.buffer.setLength(0);
- final int count = ParameterFormatter.countArgumentPlaceholders("p1={},
p2={}, p3={}, p4={}, p5={}");
- ParameterFormatter.formatMessage(state.buffer, "p1={}, p2={}, p3={},
p4={}, p5={}", ARGS, count);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency7Params(final ThreadState state) {
- state.buffer.setLength(0);
- final int count = ParameterFormatter.countArgumentPlaceholders("p1={},
p2={}, p3={}, p4={}, p5={}, p6={}, p7={}");
- ParameterFormatter.formatMessage(state.buffer, "p1={}, p2={}, p3={},
p4={}, p5={}, p6={}, p7={}", ARGS, count);
- return state.buffer.length();
- }
-
- @Benchmark
- @BenchmarkMode(Mode.SampleTime)
- @OutputTimeUnit(TimeUnit.NANOSECONDS)
- public int latency9Params(final ThreadState state) {
- state.buffer.setLength(0);
- final int count = ParameterFormatter.countArgumentPlaceholders("p1={},
p2={}, p3={}, p4={}, p5={}, p6={}, p7={}, p8={}, p9={}");
- ParameterFormatter.formatMessage(state.buffer, "p1={}, p2={}, p3={},
p4={}, p5={}, p6={}, p7={}, p8={}, p9={}", ARGS, count);
- return state.buffer.length();
- }
+// @Benchmark
Review Comment:
As I have indicated both in the email and PR description, I am working on
the benchmarks as we speak.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]