]> git.uio.no Git - ifi-stolz-refaktor.git/blobdiff - software/no.uio.ifi.refaktor/src/no/uio/ifi/refaktor/analyze/AnalysisStatistics.java
Merge branch 'master' of git.uio.no:ifi-stolz-refaktor
[ifi-stolz-refaktor.git] / software / no.uio.ifi.refaktor / src / no / uio / ifi / refaktor / analyze / AnalysisStatistics.java
index b2874f167ab1fe5863052027c459f26fc87e4081..024db7699b70bd68ad490c921114f1c55080f632 100644 (file)
@@ -1,13 +1,18 @@
 package no.uio.ifi.refaktor.analyze;
 
 public class AnalysisStatistics {
-       private int methodCount = 0;
-       private int typeCount = 0;
-       private long startTime = 0;
+       private int methodCount;
+       private int typeCount;
+       private int compilationUnitCount;
+       private int packageCount;
+       private long startTime;
+       private String timeUsed;
 
        public void reset() {
                methodCount = 0;
                typeCount = 0;
+               compilationUnitCount = 0;
+               packageCount = 0;
                startTime = System.currentTimeMillis();
        }
 
@@ -27,12 +32,46 @@ public class AnalysisStatistics {
                return typeCount;
        }
 
+       public void incrementCompilationUnitCount() {
+               compilationUnitCount++;
+       }
+
+       public int getCompilationUnitCount() {
+               return compilationUnitCount;
+       }
+
+       public void incrementPackageCount() {
+               packageCount++;
+       }
+
+       public int getPackageCount() {
+               return packageCount;
+       }
+
+       public void recordTimeUsed() {
+               timeUsed = timeSinceStart();
+       }
+
+       public String getTimeUsed() {
+               return timeUsed;
+       }
+
        public String timeSinceStart() {
-               long secondsSinceAnalysisStart = secondsSinceStart();
-               return secondsSinceAnalysisStart/60 + "m" + secondsSinceAnalysisStart % 60 + "s";
+               long durationInMillis = System.currentTimeMillis() - startTime;
+               long secondsSinceAnalysisStart = durationInMillis/1000;
+
+               if (secondsSinceAnalysisStart > 0)
+                       return secondsSinceAnalysisStart/60 + "m" + secondsSinceAnalysisStart % 60 + "s";
+               else
+                       return durationInMillis + "ms";
        }
 
-       private long secondsSinceStart() {
-               return (System.currentTimeMillis() - startTime)/1000;
+       @Override
+       public String toString() {
+               return (getPackageCount() > 0 ? "Number of packages analyzed: " + getPackageCount() : "") 
+                               + (getCompilationUnitCount() > 0 ? "\nNumber of compilation units analyzed: " + getCompilationUnitCount() : "")
+                               + (getTypeCount() > 0 ? "\nNumber of types analyzed: " + getTypeCount() : "")
+                               + "\nNumber of methods analyzed: " + getMethodCount()
+                               + "\nTime used: " + getTimeUsed();
        }
 }
\ No newline at end of file