package no.uio.ifi.refaktor.analyze;
public class AnalysisStatistics {
- private int methodCount = 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();
}
return methodCount;
}
+ public void incrementTypeCount() {
+ typeCount++;
+ }
+
+ public int getTypeCount() {
+ 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