]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorJulien HENRY <julien.henry@sonarsource.com>
Fri, 31 May 2013 06:43:49 +0000 (08:43 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Fri, 31 May 2013 06:43:49 +0000 (08:43 +0200)
sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java
sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java
sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java
sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java

index 41997fa0eef2cd3aadba1960c3c7dec6ae5d228c..a610520ef5f9b08e51a154212f5629fdb3cda6d0 100644 (file)
@@ -91,4 +91,8 @@ public abstract class AbstractTimeProfiling {
     return result;
   }
 
+  protected void println(String msg) {
+    PhasesSumUpTimeProfiler.println(msg);
+  }
+
 }
index b67b454e5738bf753ee92bc6876032d22622697e..e1b48fcba697388cfedf70fac27bd0c8305f34e8 100644 (file)
@@ -63,14 +63,14 @@ public class ModuleProfiling extends AbstractTimeProfiling {
       StringBuilder sb = new StringBuilder();
       sb.append(" * ").append(phaseProfiling.phase()).append(" execution time: ").append(phaseProfiling.totalTimeAsString())
           .append(" (").append((int) (phaseProfiling.totalTime() / percent)).append("%)");
-      System.out.println(sb.toString());
+      println(sb.toString());
     }
     for (Phase phase : Phases.Phase.values()) {
       if (profilingPerPhase.containsKey(phase)) {
         StringBuilder sb = new StringBuilder();
         sb.append("\n * ").append(phase).append(" execution time breakdown: ")
             .append(TimeUtils.formatDuration(getProfilingPerPhase(phase).totalTime()));
-        System.out.println(sb.toString());
+        println(sb.toString());
         getProfilingPerPhase(phase).dump();
       }
     }
index 581be48c74049db417427397d35896fba352ce98..8bb5bcbdacd884da880136bb405a4fc45156db83 100644 (file)
@@ -77,7 +77,7 @@ public class PhaseProfiling extends AbstractTimeProfiling {
       StringBuilder sb = new StringBuilder();
       sb.append("   o ").append(itemProfiling.itemName()).append(": ").append(itemProfiling.totalTimeAsString())
           .append(" (").append((int) (itemProfiling.totalTime() / percent)).append("%)");
-      System.out.println(sb.toString());
+      println(sb.toString());
     }
   }
 
index f1c573eaf61f8ab38f90ab1887638de97ca83483..6137b79875eece0e4f894d54a119edd2617ba494 100644 (file)
@@ -21,6 +21,8 @@ package org.sonar.batch.profiling;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Lists;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.sonar.api.batch.Decorator;
 import org.sonar.api.batch.events.DecoratorExecutionHandler;
 import org.sonar.api.batch.events.DecoratorsPhaseHandler;
@@ -44,6 +46,8 @@ import static org.sonar.batch.profiling.AbstractTimeProfiling.truncate;
 public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorExecutionHandler, DecoratorExecutionHandler, PostJobExecutionHandler, DecoratorsPhaseHandler,
     SensorsPhaseHandler, PostJobsPhaseHandler {
 
+  static Logger LOG = LoggerFactory.getLogger(PhasesSumUpTimeProfiler.class);
+
   @VisibleForTesting
   ModuleProfiling currentModuleProfiling;
   @VisibleForTesting
@@ -57,6 +61,10 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx
     this(new Clock());
   }
 
+  static void println(String msg) {
+    LOG.info(msg);
+  }
+
   @VisibleForTesting
   PhasesSumUpTimeProfiler(Clock clock) {
     this.clock = clock;
@@ -74,9 +82,9 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx
       currentModuleProfiling.stop();
       modulesProfilings.add(currentModuleProfiling);
       long moduleTotalTime = currentModuleProfiling.totalTime();
-      System.out.println("\n -------- Profiling of module " + module.getName() + ": " + TimeUtils.formatDuration(moduleTotalTime) + " --------\n");
+      println("\n -------- Profiling of module " + module.getName() + ": " + TimeUtils.formatDuration(moduleTotalTime) + " --------\n");
       currentModuleProfiling.dump();
-      System.out.println("\n -------- End of profiling of module " + module.getName() + " --------\n");
+      println("\n -------- End of profiling of module " + module.getName() + " --------\n");
       totalProfiling.merge(currentModuleProfiling);
       if (module.isRoot() && !module.getModules().isEmpty()) {
         dumpTotalExecutionSummary();
@@ -87,18 +95,18 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx
   private void dumpTotalExecutionSummary() {
     totalProfiling.stop();
     long totalTime = totalProfiling.totalTime();
-    System.out.println("\n ======== Profiling of total execution: " + TimeUtils.formatDuration(totalTime) + " ========\n");
-    System.out.println(" * Module execution time breakdown: ");
+    println("\n ======== Profiling of total execution: " + TimeUtils.formatDuration(totalTime) + " ========\n");
+    println(" * Module execution time breakdown: ");
     double percent = totalTime / 100.0;
     for (ModuleProfiling modulesProfiling : truncate(sortByDescendingTotalTime(modulesProfilings))) {
       StringBuilder sb = new StringBuilder();
       sb.append("   o ").append(modulesProfiling.moduleName()).append(" execution time: ").append(modulesProfiling.totalTimeAsString())
           .append(" (").append((int) (modulesProfiling.totalTime() / percent)).append("%)");
-      System.out.println(sb.toString());
+      println(sb.toString());
     }
-    System.out.println();
+    println("");
     totalProfiling.dump();
-    System.out.println("\n ======== End of profiling of total execution ========\n");
+    println("\n ======== End of profiling of total execution ========\n");
   }
 
   public void onSensorsPhase(SensorsPhaseEvent event) {