mnemonic-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject [11/14] incubator-mnemonic git commit: MNEMONIC-163 - Collect outputs of sort-bench to a log file
Date Mon, 21 Nov 2016 17:32:37 GMT
MNEMONIC-163 - Collect outputs of sort-bench to a log file


Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/b5fbd946
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/b5fbd946
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/b5fbd946

Branch: refs/heads/master
Commit: b5fbd94612af594d4c97771fcce1d738ff3d10b1
Parents: e30ac72
Author: Wang, Gang(Gary) <gang1.wang@intel.com>
Authored: Thu Nov 17 13:10:31 2016 -0800
Committer: Wang, Gang(Gary) <gang1.wang@intel.com>
Committed: Thu Nov 17 14:44:58 2016 -0800

----------------------------------------------------------------------
 .../java/org/apache/mnemonic/bench/Sort.java    | 27 ++++++-----
 .../src/main/resources/log4j.properties         | 33 -------------
 .../src/main/resources/logback.xml              | 49 ++++++++++++++++++++
 mnemonic-benches/pom.xml                        | 16 -------
 4 files changed, 65 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/b5fbd946/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
index daca7da..96972ce 100644
--- a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
@@ -24,7 +24,10 @@ import org.apache.commons.cli.DefaultParser;
 import org.apache.commons.cli.HelpFormatter;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.ParseException;
-import java.util.Random;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
 import java.util.concurrent.TimeUnit;
 import java.io.File;
 import java.io.BufferedReader;
@@ -39,15 +42,16 @@ import java.io.FileNotFoundException;
  * 
  */
 public class Sort {
-
   /**
    * Run workloads to bench performance.
    *
    * @param args
    *          array of commandline parameters
    */
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(Sort.class);
+
   public static void main(String[] args) throws Exception {
-    Random randomGenerator = new Random();
 
     Options options = new Options();
 
@@ -83,10 +87,11 @@ public class Sort {
         System.exit(1);
         return;
     }
+    MDC.put("mode", String.format("Mode-%s", runMode));
 
-    System.out.println(String.format("Run Mode is %s", runMode));
-    System.out.println(String.format("Input file is %s", inputFilePath));
-    System.out.println(String.format("Output file is %s", outputFilePath));
+    LOGGER.info("Run Mode : {}", runMode);
+    LOGGER.info("Input file : {}", inputFilePath);
+    LOGGER.info("Output file : {}", outputFilePath);
 
     File inputFile = new File(inputFilePath);
     File outputFile = new File(outputFilePath);
@@ -142,13 +147,13 @@ public class Sort {
   }
 
   static void reportElapse(String msg, long t1, long t2) {
-    System.out.println(String.format("%s : %,d ms.", msg,
-        TimeUnit.NANOSECONDS.toMillis(t2 - t1)));
+    LOGGER.info("{} : {} ms.", msg,
+        TimeUnit.NANOSECONDS.toMillis(t2 - t1));
   }
 
   static void reportSortInfo(long[] sortinfo) {
-    System.out.println(String.format("Scan Count: %,d ", sortinfo[0]));
-    System.out.println(String.format("Swap Count: %,d ", sortinfo[1]));
-    System.out.println(String.format("No Swap Count : %,d ", sortinfo[2]));
+    LOGGER.info("Scan Count : {} ", sortinfo[0]);
+    LOGGER.info("Swap Count : {} ", sortinfo[1]);
+    LOGGER.info("No Swap Count : {} ", sortinfo[2]);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/b5fbd946/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties b/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties
deleted file mode 100644
index 24b0e3c..0000000
--- a/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Root logger option
-log4j.rootLogger=INFO, file, stdout
-
-#to stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
-
-#to log.log file
-log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.File=log.log
-log4j.appender.file.MaxFileSize=10MB
-log4j.appender.file.MaxBackupIndex=10
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/b5fbd946/mnemonic-benches/mnemonic-sort-bench/src/main/resources/logback.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/resources/logback.xml b/mnemonic-benches/mnemonic-sort-bench/src/main/resources/logback.xml
new file mode 100644
index 0000000..367c140
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/resources/logback.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<configuration>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- encoders are assigned the type
+         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <appender name="RESULT_FILE" class="ch.qos.logback.core.FileAppender">
+    <file>sort_bench_result.log</file>
+    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+      <Pattern>%d [%thread] %-5level %X{mode} %logger{36} - %msg%n</Pattern>
+    </encoder>
+  </appender>
+
+  <logger name="org.apache.mnemonic.bench" level="INFO" additivity="false">
+   <appender-ref ref="RESULT_FILE" />
+  </logger>
+
+  <!-- Strictly speaking, the level attribute is not necessary since -->
+  <!-- the level of the root level is set to DEBUG by default.       -->
+  <root level="DEBUG">          
+    <appender-ref ref="STDOUT" />
+  </root>  
+  
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/b5fbd946/mnemonic-benches/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/pom.xml b/mnemonic-benches/pom.xml
index bf8a3c1..56ef788 100644
--- a/mnemonic-benches/pom.xml
+++ b/mnemonic-benches/pom.xml
@@ -64,22 +64,6 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>jul-to-slf4j</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>jcl-over-slf4j</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
-    </dependency>
-    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
     </dependency>


Mime
View raw message