logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1615460 - /logging/log4j/log4j2/trunk/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4jLogEventBenchmark.java
Date Sun, 03 Aug 2014 23:13:31 GMT
Author: mattsicker
Date: Sun Aug  3 23:13:31 2014
New Revision: 1615460

URL: http://svn.apache.org/r1615460
Log:
Use return values instead of BlackHole. Improves test readability since we're only generating
single values in these tests.

See the JMH samples:

http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java

http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java

Modified:
    logging/log4j/log4j2/trunk/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4jLogEventBenchmark.java

Modified: logging/log4j/log4j2/trunk/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4jLogEventBenchmark.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4jLogEventBenchmark.java?rev=1615460&r1=1615459&r2=1615460&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4jLogEventBenchmark.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/Log4jLogEventBenchmark.java
Sun Aug  3 23:13:31 2014
@@ -45,37 +45,33 @@ public class Log4jLogEventBenchmark {
     }
 
     @GenerateMicroBenchmark
-    public void testNoException(final BlackHole bh) {
-        final Throwable t = null;
-        final Log4jLogEvent event = new Log4jLogEvent("a.b.c", null, "a.b.c", Level.INFO,
MESSAGE, t);
-        bh.consume(event);
+    public LogEvent createLogEventWithoutException() {
+        return new Log4jLogEvent("a.b.c", null, "a.b.c", Level.INFO, MESSAGE, null);
     }
 
     @GenerateMicroBenchmark
-    public void testNoExceptionUsingBuilder(final BlackHole bh) {
-        final LogEvent event = Log4jLogEvent.newBuilder()
+    public LogEvent createLogEventWithoutExceptionUsingBuilder() {
+        return Log4jLogEvent.newBuilder()
             .setLoggerName("a.b.c")
             .setLoggerFqcn("a.b.c")
             .setLevel(Level.INFO)
             .setMessage(MESSAGE)
             .build();
-        bh.consume(event);
     }
 
     @GenerateMicroBenchmark
-    public void testException(final BlackHole bh) {
-        final LogEvent event = Log4jLogEvent.newBuilder()
+    public LogEvent createLogEventWithExceptionUsingBuilder() {
+        return Log4jLogEvent.newBuilder()
             .setLoggerName("a.b.c")
             .setLoggerFqcn("a.b.c")
             .setLevel(Level.INFO)
             .setMessage(MESSAGE)
             .setThrown(ERROR)
             .build();
-        bh.consume(event);
     }
 
     @GenerateMicroBenchmark
-    public void testSourceLocation(final BlackHole bh) {
+    public StackTraceElement getSourceLocationOfLogEvent() {
         final LogEvent event = Log4jLogEvent.newBuilder()
             .setLoggerName(this.getClass().getName())
             .setLoggerFqcn(this.getClass().getName())
@@ -83,22 +79,19 @@ public class Log4jLogEventBenchmark {
             .setMessage(MESSAGE)
             .build();
         event.setIncludeLocation(true);
-        final StackTraceElement source = event.getSource();
-        bh.consume(source);
+        return event.getSource();
     }
 
     @GenerateMicroBenchmark
-    public void testSerializationWithoutException(final BlackHole bh) {
+    public Serializable createSerializableLogEventProxyWithoutException() {
         final Log4jLogEvent event = new Log4jLogEvent("a.b.c", null, "a.b.c", Level.INFO,
MESSAGE, null);
-        final Serializable serializable = Log4jLogEvent.serialize(event, false);
-        bh.consume(serializable);
+        return Log4jLogEvent.serialize(event, false);
     }
 
     @GenerateMicroBenchmark
-    public void testSerializationWithException(final BlackHole bh) {
+    public Serializable createSerializableLogEventProxyWithException(final BlackHole bh)
{
         final Log4jLogEvent event = new Log4jLogEvent("a.b.c", null, "a.b.c", Level.INFO,
MESSAGE, ERROR);
-        final Serializable serializable = Log4jLogEvent.serialize(event, false);
-        bh.consume(serializable);
+        return Log4jLogEvent.serialize(event, false);
     }
 
     // ============================== HOW TO RUN THIS TEST: ====================================



Mime
View raw message