]> git.uio.no Git - ifi-stolz-refaktor.git/blob - 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
1 package no.uio.ifi.refaktor.analyze;
2
3 public class AnalysisStatistics {
4         private int methodCount;
5         private int typeCount;
6         private int compilationUnitCount;
7         private int packageCount;
8         private long startTime;
9         private String timeUsed;
10
11         public void reset() {
12                 methodCount = 0;
13                 typeCount = 0;
14                 compilationUnitCount = 0;
15                 packageCount = 0;
16                 startTime = System.currentTimeMillis();
17         }
18
19         public void incrementMethodCount() {
20                 methodCount++;
21         }
22
23         public int getMethodCount() {
24                 return methodCount;
25         }
26
27         public void incrementTypeCount() {
28                 typeCount++;
29         }
30
31         public int getTypeCount() {
32                 return typeCount;
33         }
34
35         public void incrementCompilationUnitCount() {
36                 compilationUnitCount++;
37         }
38
39         public int getCompilationUnitCount() {
40                 return compilationUnitCount;
41         }
42
43         public void incrementPackageCount() {
44                 packageCount++;
45         }
46
47         public int getPackageCount() {
48                 return packageCount;
49         }
50
51         public void recordTimeUsed() {
52                 timeUsed = timeSinceStart();
53         }
54
55         public String getTimeUsed() {
56                 return timeUsed;
57         }
58
59         public String timeSinceStart() {
60                 long durationInMillis = System.currentTimeMillis() - startTime;
61                 long secondsSinceAnalysisStart = durationInMillis/1000;
62
63                 if (secondsSinceAnalysisStart > 0)
64                         return secondsSinceAnalysisStart/60 + "m" + secondsSinceAnalysisStart % 60 + "s";
65                 else
66                         return durationInMillis + "ms";
67         }
68
69         @Override
70         public String toString() {
71                 return (getPackageCount() > 0 ? "Number of packages analyzed: " + getPackageCount() : "") 
72                                 + (getCompilationUnitCount() > 0 ? "\nNumber of compilation units analyzed: " + getCompilationUnitCount() : "")
73                                 + (getTypeCount() > 0 ? "\nNumber of types analyzed: " + getTypeCount() : "")
74                                 + "\nNumber of methods analyzed: " + getMethodCount()
75                                 + "\nTime used: " + getTimeUsed();
76         }
77 }