1 package no.uio.ifi.refaktor.aspects;
3 import no.uio.ifi.refaktor.analyze.analyzers.SearchBasedExtractAndMoveMethodAnalyzer;
4 import no.uio.ifi.refaktor.utils.RefaktorDebug;
6 import org.eclipse.jdt.core.IMethod;
7 import org.eclipse.jdt.core.JavaModelException;
9 privileged public aspect StatisticsAspect {
10 private long startTime;
11 private int methodCount;
13 pointcut methodAnalyze(SearchBasedExtractAndMoveMethodAnalyzer analyzer) :
14 call(* SearchBasedExtractAndMoveMethodAnalyzer.analyze()) && target(analyzer);
16 before(SearchBasedExtractAndMoveMethodAnalyzer analyzer) : methodAnalyze(analyzer) {
18 debugPrintMethodAnalysisProgress(analyzer.method);
21 private void debugPrintMethodAnalysisProgress(IMethod method) {
23 RefaktorDebug.println("#" + methodCount + " (" + timeSinceStart() + "): "
24 + method.getDeclaringType().getElementName() + "." + method.getElementName() + " (" + "offset: "
25 + method.getSourceRange().getOffset() + ", length: " + method.getSourceRange().getLength() + ")");
26 } catch (JavaModelException e) {
27 RefaktorDebug.println("No info about " + method.getElementName());
32 startTime = System.currentTimeMillis();
36 public String timeSinceStart() {
37 long durationInMillis = System.currentTimeMillis() - startTime;
38 long secondsSinceAnalysisStart = durationInMillis/1000;
40 if (secondsSinceAnalysisStart > 0)
41 return secondsSinceAnalysisStart/60 + "m" + secondsSinceAnalysisStart % 60 + "s";
43 return durationInMillis + "ms";
46 public int getMethodCount() {
51 // public String toString() {
52 // return (getPackageCount() > 0 ? "Number of packages analyzed: " + getPackageCount() : "")
53 // + (getCompilationUnitCount() > 0 ? "\nNumber of compilation units analyzed: " + getCompilationUnitCount() : "")
54 // + (getTypeCount() > 0 ? "\nNumber of types analyzed: " + getTypeCount() : "")
55 // + "\nNumber of methods analyzed: " + getMethodCount()
56 // + "\nTime used: " + getTimeUsed();