You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2015/09/19 08:15:51 UTC

logging-log4j2 git commit: LOG4J2-1121 added benchmark for reconfiguration

Repository: logging-log4j2
Updated Branches:
  refs/heads/master c69beb222 -> 82ddb5899


LOG4J2-1121 added benchmark for reconfiguration

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/82ddb589
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/82ddb589
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/82ddb589

Branch: refs/heads/master
Commit: 82ddb58995fb3f820ca9b7533c20c6a9242b06fc
Parents: c69beb2
Author: rpopma <rp...@apache.org>
Authored: Sat Sep 19 15:15:50 2015 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sat Sep 19 15:15:50 2015 +0900

----------------------------------------------------------------------
 .../log4j/perf/jmh/LoggerConfigBenchmark.java   | 33 ++++++++++++--------
 1 file changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/82ddb589/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/LoggerConfigBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/LoggerConfigBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/LoggerConfigBenchmark.java
index 2f6cd95..937b5bb 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/LoggerConfigBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/LoggerConfigBenchmark.java
@@ -115,6 +115,12 @@ public class LoggerConfigBenchmark {
         return listAppender.size();
     }
 
+    @Benchmark
+    public int logWithCountersRetryAfterReconfig() {
+        log4WithCounterAndFlag(LOGEVENT);
+        return listAppender.size();
+    }
+
     /**
      * Logs an event.
      *
@@ -152,27 +158,28 @@ public class LoggerConfigBenchmark {
      *
      * @param event The log event.
      */
-    public void logWithCounterAndFlag(final LogEvent event) {
-        while (!beforeLogEventCheckCounterPositive()) {
-
-        }
-        try {
-            if (!isFiltered(event)) {
-                processLogEvent(event);
-            }
-        } finally {
-            afterLogEvent2();
+    public void log3(final LogEvent event) {
+        if (!isFiltered(event)) {
+            processLogEvent(event);
         }
     }
+    
+    volatile LoggerConfigBenchmark loggerConfig = this;
 
     /**
      * Logs an event.
      *
      * @param event The log event.
      */
-    public void log3(final LogEvent event) {
-        if (!isFiltered(event)) {
-            processLogEvent(event);
+    public void log4WithCounterAndFlag(final LogEvent event) {
+        LoggerConfigBenchmark local = loggerConfig;
+        while (!local.beforeLogEventCheckCounterPositive()) {
+            local = loggerConfig;
+        }
+        try {
+            local.log3(event);
+        } finally {
+            local.afterLogEvent2();
         }
     }