aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-10-28 16:29:05 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2014-10-28 16:39:03 +0100
commitdc5bbf3ed6fdf9cb2aecbe552b4e4a6e6eb673b3 (patch)
tree97ffad6d7f14102448010ca08d3695eb09a71091 /sonar-batch
parent53369f1e6cd2ac9bd24cc2d4465700ce69b73725 (diff)
downloadsonarqube-dc5bbf3ed6fdf9cb2aecbe552b4e4a6e6eb673b3.tar.gz
sonarqube-dc5bbf3ed6fdf9cb2aecbe552b4e4a6e6eb673b3.zip
Fix profiling output
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java10
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java4
4 files changed, 15 insertions, 7 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java
index c1ac193cf28..fc8634f6f70 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java
@@ -85,7 +85,7 @@ public class ModuleProfiling extends AbstractTimeProfiling {
if (profilingPerPhase.containsKey(phase) && getProfilingPerPhase(phase).hasItems()) {
println("");
println(" * " + phase + " execution time breakdown: ", getProfilingPerPhase(phase));
- getProfilingPerPhase(phase).dump();
+ getProfilingPerPhase(phase).dump(props);
}
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java
index 733cebe29f7..358db0d7b9c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java
@@ -25,6 +25,7 @@ import org.sonar.batch.phases.Phases.Phase;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
public class PhaseProfiling extends AbstractTimeProfiling {
@@ -73,8 +74,11 @@ public class PhaseProfiling extends AbstractTimeProfiling {
}
}
- public void dump() {
+ public void dump(Properties props) {
double percent = this.totalTime() / 100.0;
+ for (ItemProfiling itemProfiling : profilingPerItem.values()) {
+ props.setProperty(itemProfiling.itemName(), "" + itemProfiling.totalTime());
+ }
for (ItemProfiling itemProfiling : truncate(sortByDescendingTotalTime(profilingPerItem).values())) {
println(" o " + itemProfiling.itemName() + ": ", percent, itemProfiling);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java
index da7ec7818e6..6e538f887ad 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java
@@ -25,6 +25,7 @@ import com.google.common.io.Closeables;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.sonar.api.CoreProperties;
import org.sonar.api.batch.Decorator;
import org.sonar.api.batch.events.DecoratorExecutionHandler;
import org.sonar.api.batch.events.DecoratorsPhaseHandler;
@@ -38,8 +39,8 @@ import org.sonar.api.batch.events.SensorExecutionHandler;
import org.sonar.api.batch.events.SensorsPhaseHandler;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.System2;
-import org.sonar.api.utils.TempFolder;
import org.sonar.api.utils.TimeUtils;
+import org.sonar.batch.bootstrap.BootstrapProperties;
import org.sonar.batch.events.BatchStepHandler;
import org.sonar.batch.phases.Phases;
import org.sonar.batch.phases.event.PersisterExecutionHandler;
@@ -91,8 +92,11 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx
println(sb.toString());
}
- public PhasesSumUpTimeProfiler(System2 system, TempFolder tempFolder) {
- this.out = tempFolder.newDir("profiling");
+ public PhasesSumUpTimeProfiler(System2 system, BootstrapProperties bootstrapProps) {
+ String workingDirPath = StringUtils.defaultIfBlank(bootstrapProps.property(CoreProperties.WORKING_DIRECTORY), CoreProperties.WORKING_DIRECTORY_DEFAULT_VALUE);
+ File workingDir = new File(workingDirPath).getAbsoluteFile();
+ this.out = new File(workingDir, "profiling");
+ this.out.mkdirs();
this.totalProfiling = new ModuleProfiling(null, system);
this.system = system;
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java b/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java
index 67a25b2c439..a22bee54b7d 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java
@@ -45,7 +45,7 @@ import org.sonar.api.batch.events.SensorsPhaseHandler.SensorsPhaseEvent;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.utils.System2;
-import org.sonar.api.utils.internal.DefaultTempFolder;
+import org.sonar.batch.bootstrap.BootstrapProperties;
import org.sonar.batch.events.BatchStepEvent;
import org.sonar.batch.index.ScanPersister;
import org.sonar.batch.phases.Phases.Phase;
@@ -72,7 +72,7 @@ public class PhasesSumUpTimeProfilerTest {
@Before
public void prepare() throws IOException {
clock = new MockedSystem();
- profiler = new PhasesSumUpTimeProfiler(clock, new DefaultTempFolder(temp.newFolder()));
+ profiler = new PhasesSumUpTimeProfiler(clock, new BootstrapProperties(Collections.<String, String>emptyMap()));
}
@Test