]> source.dussan.org Git - sonarqube.git/commitdiff
Add profiling logs to analysis report exchange protocol
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 26 Jan 2015 17:07:25 +0000 (18:07 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 26 Jan 2015 17:07:34 +0000 (18:07 +0100)
server/sonar-server/src/main/java/org/sonar/server/computation/ComputationService.java
sonar-batch/src/main/java/org/sonar/batch/report/PublishReportJob.java

index 804d69fa62845f1bda54836e3484cee3c5a26033..dc798c81e2b9197632c025c7194334e06ede8ebf 100644 (file)
@@ -105,11 +105,14 @@ public class ComputationService implements ServerComponent {
   }
 
   private void decompressReport(AnalysisReportDto report, File toDir) {
+    long startTime = System.currentTimeMillis();
     DbSession session = dbClient.openSession(false);
     try {
       dbClient.analysisReportDao().selectAndDecompressToDir(session, report.getId(), toDir);
     } finally {
       MyBatis.closeQuietly(session);
     }
+    long stoptTime = System.currentTimeMillis();
+    LOG.info("Analysis report loaded and uncompressed in " + (stoptTime-startTime) + "ms (project=" + report.getProjectKey() +")");
   }
 }
index 22aa61b0d1a45b26cdcfedc34c65137b92143380..3469f1dd262f165e193ef8dca89a3668f0363458 100644 (file)
@@ -83,15 +83,21 @@ public class PublishReportJob implements BatchComponent {
 
   private File prepareReport() {
     try {
+      long startTime = System.currentTimeMillis();
       File reportDir = temp.newDir("batch-report");
       ReportHelper reportHelper = ReportHelper.create(reportDir);
       for (ReportPublisher publisher : publishers) {
         publisher.export(reportHelper);
       }
+      long stopTime = System.currentTimeMillis();
+      LOG.debug("Analysis reports generated in " + (stopTime - startTime) + "ms");
 
+      startTime = System.currentTimeMillis();
       File reportZip = temp.newFile("batch-report", ".zip");
       ZipUtils.zipDir(reportDir, reportZip);
       FileUtils.deleteDirectory(reportDir);
+      stopTime = System.currentTimeMillis();
+      LOG.debug("Analysis reports compressed in " + (stopTime - startTime) + "ms, zip size=" + FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(reportZip)));
       return reportZip;
     } catch (IOException e) {
       throw new IllegalStateException("Unable to prepare batch report", e);
@@ -101,6 +107,7 @@ public class PublishReportJob implements BatchComponent {
   @VisibleForTesting
   void uploadMultiPartReport(File report) {
     LOG.debug("Publish results");
+    long startTime = System.currentTimeMillis();
     URL url;
     try {
       int snapshotId = resourceCache.get(project.getEffectiveKey()).snapshotId();
@@ -125,6 +132,8 @@ public class PublishReportJob implements BatchComponent {
       }
       throw new IllegalStateException(String.format("Fail to execute request [code=%s, url=%s]: %s", responseCode, url, request.body()));
     }
+    long stopTime = System.currentTimeMillis();
+    LOG.debug("Analysis reports sent to server in " + (stopTime - startTime) + "ms");
   }
 
   @VisibleForTesting