Add benchmark for logging a Message
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/18f108d3 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/18f108d3 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/18f108d3 Branch: refs/heads/master Commit: 18f108d3a15e733819405d7d122bd4ab99e107a9 Parents: 232043c Author: Ralph Goers <[email protected]> Authored: Sat Jan 23 22:40:03 2016 -0700 Committer: Ralph Goers <[email protected]> Committed: Sun Jan 24 00:38:05 2016 -0700 ---------------------------------------------------------------------- .../logging/log4j/perf/jmh/SimpleBenchmark.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/18f108d3/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/SimpleBenchmark.java ---------------------------------------------------------------------- diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/SimpleBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/SimpleBenchmark.java index 543fe8d..8d1f189 100644 --- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/SimpleBenchmark.java +++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/SimpleBenchmark.java @@ -25,6 +25,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.DefaultConfiguration; +import org.apache.logging.log4j.message.SimpleMessage; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; @@ -86,6 +87,14 @@ public class SimpleBenchmark { logger.debug(msg); } + + @BenchmarkMode(Mode.Throughput) + @OutputTimeUnit(TimeUnit.SECONDS) + @Benchmark + public void testDebugMessageDisabledThroughput(final Blackhole bh) { + logger.debug(new SimpleMessage(msg)); + } + @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Benchmark @@ -112,4 +121,11 @@ public class SimpleBenchmark { public void testDebugDisabledResponseTime(final Blackhole bh) { logger.debug(msg); } + + @BenchmarkMode(Mode.SampleTime) + @OutputTimeUnit(TimeUnit.NANOSECONDS) + @Benchmark + public void testDebugDisabledMessageResponseTime(final Blackhole bh) { + logger.debug(new SimpleMessage(msg)); + } }
