package no.uio.ifi.refaktor.analyze;
+import no.uio.ifi.refaktor.aspects.StatisticsAspect;
+
public class AnalysisStatistics {
- private int typeCount;
private int compilationUnitCount;
private int packageCount;
private long startTime;
private String timeUsed;
public void reset() {
- typeCount = 0;
compilationUnitCount = 0;
packageCount = 0;
startTime = System.currentTimeMillis();
}
- public void incrementTypeCount() {
- typeCount++;
- }
-
- public int getTypeCount() {
- return typeCount;
- }
-
public void incrementCompilationUnitCount() {
compilationUnitCount++;
}
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() : "")
+ + (StatisticsAspect.aspectOf().getTypeCount() > 0 ? "\nNumber of types analyzed: " + StatisticsAspect.aspectOf().getTypeCount() : "")
+ + "\nNumber of methods analyzed: " + StatisticsAspect.aspectOf().getMethodCount()
+ "\nTime used: " + getTimeUsed();
}
}
\ No newline at end of file
}
private void analyzeMethodsInType(IType type) throws JavaModelException {
- TypeWideExtractAndMoveMethodAnalyzer analyzer = new TypeWideExtractAndMoveMethodAnalyzer(type, statistics);
+ TypeWideExtractAndMoveMethodAnalyzer analyzer = new TypeWideExtractAndMoveMethodAnalyzer(type);
analyzer.analyze();
results.addAll(analyzer.getResults());
}
import java.util.LinkedList;
import java.util.List;
-import no.uio.ifi.refaktor.analyze.AnalysisStatistics;
import no.uio.ifi.refaktor.analyze.ExtractAndMoveMethodAnalysisResult;
import no.uio.ifi.refaktor.analyze.comparators.FavorNoUnfixesAnalysisResultComparator;
import no.uio.ifi.refaktor.analyze.exceptions.NoTargetFoundException;
public class TypeWideExtractAndMoveMethodAnalyzer implements AggregationAnalyzer<ExtractAndMoveMethodAnalysisResult> {
private final IType type;
- private final AnalysisStatistics statistics;
private final List<ExtractAndMoveMethodAnalysisResult> results;
- public TypeWideExtractAndMoveMethodAnalyzer(IType type, AnalysisStatistics statistics) {
+ public TypeWideExtractAndMoveMethodAnalyzer(IType type) {
this.type = type;
- this.statistics = statistics;
results = new LinkedList<ExtractAndMoveMethodAnalysisResult>();
}
} catch (JavaModelException e) {
RefaktorDebug.log(e);
}
- statistics.incrementTypeCount();
}
private void analyzeMethodsInType() throws JavaModelException {
package no.uio.ifi.refaktor.aspects;
import no.uio.ifi.refaktor.analyze.analyzers.SearchBasedExtractAndMoveMethodAnalyzer;
+import no.uio.ifi.refaktor.analyze.analyzers.TypeWideExtractAndMoveMethodAnalyzer;
import no.uio.ifi.refaktor.utils.RefaktorDebug;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.JavaModelException;
+
privileged public aspect StatisticsAspect {
private long startTime;
private int methodCount;
+ private int typeCount;
pointcut methodAnalyze(SearchBasedExtractAndMoveMethodAnalyzer analyzer) :
call(* SearchBasedExtractAndMoveMethodAnalyzer.analyze()) && target(analyzer);
+ pointcut typeAnalyze() : call(* TypeWideExtractAndMoveMethodAnalyzer.analyze());
+
before(SearchBasedExtractAndMoveMethodAnalyzer analyzer) : methodAnalyze(analyzer) {
methodCount++;
debugPrintMethodAnalysisProgress(analyzer.method);
}
}
+ after(): typeAnalyze() {
+ typeCount++;
+ }
+
public void init() {
startTime = System.currentTimeMillis();
methodCount = 0;
+ typeCount = 0;
}
public String timeSinceStart() {
public int getMethodCount() {
return methodCount;
}
+
+ public int getTypeCount() {
+ return typeCount;
+ }
// @Override
// public String toString() {
protected AggregationAnalyzer createAnalyzer(Object element, AnalysisStatistics statistics) {
assertThat(element, instanceOf(IType.class));
IType type = (IType) element;
- return new TypeWideExtractAndMoveMethodAnalyzer(type, statistics);
+ return new TypeWideExtractAndMoveMethodAnalyzer(type);
}
}