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 2014/07/06 04:05:27 UTC

svn commit: r1608150 - /logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java

Author: rpopma
Date: Sun Jul  6 02:05:27 2014
New Revision: 1608150

URL: http://svn.apache.org/r1608150
Log:
removed underscore prefix from instance variables in async performance test class

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java?rev=1608150&r1=1608149&r2=1608150&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java Sun Jul  6 02:05:27 2014
@@ -41,27 +41,27 @@ public class PerfTestDriver {
      * Defines the setup for a java process running a performance test.
      */
     static class Setup implements Comparable<Setup> {
-        private final Class<?> _class;
-        private final String _log4jConfig;
-        private final String _name;
-        private final String[] _systemProperties;
-        private final int _threadCount;
-        private final File _temp;
-        public Stats _stats;
-        private final WaitStrategy _wait;
-        private final String _runner;
+        private final Class<?> klass;
+        private final String log4jConfig;
+        private final String name;
+        private final String[] systemProperties;
+        private final int threadCount;
+        private final File temp;
+        public Stats stats;
+        private final WaitStrategy wait;
+        private final String runner;
 
         public Setup(final Class<?> klass, final String runner, final String name,
                 final String log4jConfig, final int threadCount, final WaitStrategy wait,
                 final String... systemProperties) throws IOException {
-            _class = klass;
-            _runner = runner;
-            _name = name;
-            _log4jConfig = log4jConfig;
-            _threadCount = threadCount;
-            _systemProperties = systemProperties;
-            _wait = wait;
-            _temp = File.createTempFile("log4jperformance", ".txt");
+            this.klass = klass;
+            this.runner = runner;
+            this.name = name;
+            this.log4jConfig = log4jConfig;
+            this.threadCount = threadCount;
+            this.systemProperties = systemProperties;
+            this.wait = wait;
+            this.temp = File.createTempFile("log4jperformance", ".txt");
         }
 
         List<String> processArguments(final String java) {
@@ -80,27 +80,27 @@ public class PerfTestDriver {
             // args.add("-XX:+PrintGCApplicationConcurrentTime");
             // args.add("-XX:+PrintSafepointStatistics");
 
-            args.add("-Dlog4j.configuration=" + _log4jConfig); // log4j 1.2
-            args.add("-Dlog4j.configurationFile=" + _log4jConfig); // log4j 2
-            args.add("-Dlogback.configurationFile=" + _log4jConfig);// logback
+            args.add("-Dlog4j.configuration=" + log4jConfig); // log4j 1.2
+            args.add("-Dlog4j.configurationFile=" + log4jConfig); // log4j 2
+            args.add("-Dlogback.configurationFile=" + log4jConfig);// logback
 
             final int ringBufferSize = getUserSpecifiedRingBufferSize();
             if (ringBufferSize >= 128) {
                 args.add("-DAsyncLoggerConfig.RingBufferSize=" + ringBufferSize);
                 args.add("-DAsyncLogger.RingBufferSize=" + ringBufferSize);
             }
-            args.add("-DAsyncLoggerConfig.WaitStrategy=" + _wait);
-            args.add("-DAsyncLogger.WaitStrategy=" + _wait);
-            if (_systemProperties != null) {
-                Collections.addAll(args, _systemProperties);
+            args.add("-DAsyncLoggerConfig.WaitStrategy=" + wait);
+            args.add("-DAsyncLogger.WaitStrategy=" + wait);
+            if (systemProperties != null) {
+                Collections.addAll(args, systemProperties);
             }
             args.add("-cp");
             args.add(System.getProperty("java.class.path"));
-            args.add(_class.getName());
-            args.add(_runner);
-            args.add(_name);
-            args.add(_temp.getAbsolutePath());
-            args.add(String.valueOf(_threadCount));
+            args.add(klass.getName());
+            args.add(runner);
+            args.add(name);
+            args.add(temp.getAbsolutePath());
+            args.add(String.valueOf(threadCount));
             return args;
         }
 
@@ -126,19 +126,19 @@ public class PerfTestDriver {
         @Override
         public int compareTo(final Setup other) {
             // largest ops/sec first
-            return (int) Math.signum(other._stats._averageOpsPerSec
-                    - _stats._averageOpsPerSec);
+            return (int) Math.signum(other.stats.averageOpsPerSec
+                    - stats.averageOpsPerSec);
         }
 
         public String description() {
-            String detail = _class.getSimpleName();
-            if (PerfTest.class == _class) {
+            String detail = klass.getSimpleName();
+            if (PerfTest.class == klass) {
                 detail = "single thread";
-            } else if (MtPerfTest.class == _class) {
-                detail = _threadCount + " threads";
+            } else if (MtPerfTest.class == klass) {
+                detail = threadCount + " threads";
             }
-            final String target = _runner.substring(_runner.indexOf(".Run") + 4);
-            return target + ": " + _name + " (" + detail + ')';
+            final String target = runner.substring(runner.indexOf(".Run") + 4);
+            return target + ": " + name + " (" + detail + ')';
         }
     }
 
@@ -146,13 +146,13 @@ public class PerfTestDriver {
      * Results of a performance test.
      */
     static class Stats {
-        int _count;
-        long _average;
-        long _pct99;
-        long _pct99_99;
-        double _latencyRowCount;
-        int _throughputRowCount;
-        private long _averageOpsPerSec;
+        int count;
+        long average;
+        long pct99;
+        long pct99_99;
+        double latencyRowCount;
+        int throughputRowCount;
+        private long averageOpsPerSec;
 
         // example line: avg=828 99%=1118 99.99%=5028 Count=3125
         public Stats(final String raw) {
@@ -160,31 +160,31 @@ public class PerfTestDriver {
             long totalOps = 0;
             for (final String line : lines) {
                 if (line.startsWith("avg")) {
-                    _latencyRowCount++;
+                    latencyRowCount++;
                     final String[] parts = line.split(" ");
                     int i = 0;
-                    _average += Long.parseLong(parts[i++].split("=")[1]);
-                    _pct99 += Long.parseLong(parts[i++].split("=")[1]);
-                    _pct99_99 += Long.parseLong(parts[i++].split("=")[1]);
-                    _count += Integer.parseInt(parts[i].split("=")[1]);
+                    average += Long.parseLong(parts[i++].split("=")[1]);
+                    pct99 += Long.parseLong(parts[i++].split("=")[1]);
+                    pct99_99 += Long.parseLong(parts[i++].split("=")[1]);
+                    count += Integer.parseInt(parts[i].split("=")[1]);
                 } else {
-                    _throughputRowCount++;
+                    throughputRowCount++;
                     final String number = line.substring(0, line.indexOf(' '));
                     final long opsPerSec = Long.parseLong(number);
                     totalOps += opsPerSec;
                 }
             }
-            _averageOpsPerSec = totalOps / _throughputRowCount;
+            averageOpsPerSec = totalOps / throughputRowCount;
         }
 
         @Override
         public String toString() {
             final String fmt = "throughput: %,d ops/sec. latency(ns): avg=%.1f 99%% < %.1f 99.99%% < %.1f (%d samples)";
-            return String.format(fmt, _averageOpsPerSec, //
-                    _average / _latencyRowCount, // mean latency
-                    _pct99 / _latencyRowCount, // 99% observations less than
-                    _pct99_99 / _latencyRowCount,// 99.99% observs less than
-                    _count);
+            return String.format(fmt, averageOpsPerSec, //
+                    average / latencyRowCount, // mean latency
+                    pct99 / latencyRowCount, // 99% observations less than
+                    pct99_99 / latencyRowCount,// 99.99% observs less than
+                    count);
         }
     }
 
@@ -296,16 +296,16 @@ public class PerfTestDriver {
             final ProcessBuilder pb = config.throughputTest(java);
             pb.redirectErrorStream(true); // merge System.out and System.err
             final long t1 = System.nanoTime();
-            final int count = config._threadCount >= 4 ? 3 : repeat;
+            final int count = config.threadCount >= 4 ? 3 : repeat;
             runPerfTest(count, x++, config, pb);
             System.out.printf(" took %.1f seconds%n", (System.nanoTime() - t1)
                     / (1000.0 * 1000.0 * 1000.0));
 
-            final FileReader reader = new FileReader(config._temp);
+            final FileReader reader = new FileReader(config.temp);
             final CharBuffer buffer = CharBuffer.allocate(256 * 1024);
             reader.read(buffer);
             reader.close();
-            config._temp.delete();
+            config.temp.delete();
             buffer.flip();
 
             final String raw = buffer.toString();
@@ -313,7 +313,7 @@ public class PerfTestDriver {
             final Stats stats = new Stats(raw);
             System.out.println(stats);
             System.out.println("-----");
-            config._stats = stats;
+            config.stats = stats;
         }
         new File("perftest.log").delete();
         System.out
@@ -331,7 +331,7 @@ public class PerfTestDriver {
         for (int i = 0; i < tests.length; i++) {
             final Setup setup = tests[i];
             System.out.println((i + 1) + ". " + setup.description() + ": "
-                    + setup._stats);
+                    + setup.stats);
         }
     }
 
@@ -347,7 +347,7 @@ public class PerfTestDriver {
             stop[0] = true;
 
             final File gc = new File("gc" + setupIndex + '_' + i
-                    + config._log4jConfig + ".log");
+                    + config.log4jConfig + ".log");
             if (gc.exists()) {
                 gc.delete();
             }