aplcache

Details

pom.xml 6(+0 -6)

diff --git a/pom.xml b/pom.xml
index f4e22e3..609f1b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,12 +23,6 @@
             <artifactId>commons-lang3</artifactId>
             <version>3.5</version>
         </dependency>
-        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-            <version>2.8.5</version>
-        </dependency>
         <dependency>
             <groupId>br.ufrgs.inf.prosoft.trace</groupId>
             <artifactId>Trace</artifactId>
diff --git a/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/analysis/decision/flowchart/FlowchartWorkFlow.java b/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/analysis/decision/flowchart/FlowchartWorkFlow.java
index 738cc0b..38e05d0 100644
--- a/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/analysis/decision/flowchart/FlowchartWorkFlow.java
+++ b/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/analysis/decision/flowchart/FlowchartWorkFlow.java
@@ -22,7 +22,7 @@ public final class FlowchartWorkFlow {
     private void countStats() {
         logger.log(Level.INFO, "Counting stats of {0} methods", this.methods.size());
         Collections.sort(this.methods, (m1, m2) -> Integer.compare(m1.getOccurrencesSize(), m2.getOccurrencesSize()));
-        this.methods.stream().parallel().forEach(Method::countStats);
+        this.methods.stream().parallel().forEach(Method::calculateMetrics);
     }
 
     private void calculateThresholds() {
diff --git a/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/analysis/decision/flowchart/stats/CacheabilityMetrics.java b/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/analysis/decision/flowchart/stats/CacheabilityMetrics.java
index 47822bf..9dd0a0a 100644
--- a/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/analysis/decision/flowchart/stats/CacheabilityMetrics.java
+++ b/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/analysis/decision/flowchart/stats/CacheabilityMetrics.java
@@ -6,10 +6,10 @@ import java.util.Optional;
 public class CacheabilityMetrics {
 
     public static Optional<Boolean> isStaticData(GroupOfOccurrences groupOfOccurrences) {
-        if (groupOfOccurrences.getStats().getNumberOfSameOccurrences() < Thresholds.frequencyThreshold(0)) {
+        if (groupOfOccurrences.getMetrics().getNumberOfSameOccurrences() < Thresholds.frequencyThreshold(0)) {
             return Optional.empty();
         }
-        if (groupOfOccurrences.getStats().getHitRatio() == 100.0) {
+        if (groupOfOccurrences.getMetrics().getHitRatio() == 100.0) {
             return Optional.of(true);
         } else {
             return Optional.of(false);
@@ -18,7 +18,7 @@ public class CacheabilityMetrics {
 
     public static Optional<Boolean> changeMoreThanUsed(GroupOfOccurrences groupOfOccurrences) {
         //+/- k sds
-        if (groupOfOccurrences.getStats().getMissRatio() > Thresholds.missThreshold(0)) {
+        if (groupOfOccurrences.getMetrics().getMissRatio() > Thresholds.missThreshold(0)) {
             return Optional.of(true);
         } else {
             return Optional.of(false);
@@ -26,7 +26,7 @@ public class CacheabilityMetrics {
     }
 
     public static Optional<Boolean> usedByManyRequests(GroupOfOccurrences groupOfOccurrences) {
-        if (groupOfOccurrences.getStats().getNumberOfSameOccurrences() >= Thresholds.frequencyThreshold(0)) {
+        if (groupOfOccurrences.getMetrics().getNumberOfSameOccurrences() >= Thresholds.frequencyThreshold(0)) {
             return Optional.of(true);
         } else {
             return Optional.of(false);
@@ -34,12 +34,12 @@ public class CacheabilityMetrics {
     }
 
     public static Optional<Boolean> isUserSpecific(GroupOfOccurrences groupOfOccurrences) {
-        if (groupOfOccurrences.getStats().getAmountOfIdentifiedSameOccurences() == 0) {
+        if (groupOfOccurrences.getMetrics().getAmountOfIdentifiedSameOccurences() == 0) {
             return Optional.empty();
         }
 
         //the less shareable, the more user specific
-        if (groupOfOccurrences.getStats().getShareability() < Thresholds.shareabilityThreshold(0)) {
+        if (groupOfOccurrences.getMetrics().getShareability() < Thresholds.shareabilityThreshold(0)) {
             return Optional.of(true);
         } else {
             return Optional.of(false);
@@ -47,7 +47,7 @@ public class CacheabilityMetrics {
     }
 
     public static Optional<Boolean> isExpensive(GroupOfOccurrences groupOfOccurrences) {
-        if (groupOfOccurrences.getStats().getSameOccurrencesAverageExecutionTime() >= Thresholds.expensivenessThreshold(0)) {
+        if (groupOfOccurrences.getMetrics().getSameOccurrencesAverageExecutionTime() >= Thresholds.expensivenessThreshold(0)) {
             return Optional.of(true);
         } else {
             return Optional.of(false);
diff --git a/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/GroupOfOccurrences.java b/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/GroupOfOccurrences.java
index dc6c93e..8baf8bf 100644
--- a/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/GroupOfOccurrences.java
+++ b/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/GroupOfOccurrences.java
@@ -5,7 +5,7 @@
  */
 package br.ufrgs.inf.prosoft.adaptivecaching.monitoring.application.metadata;
 
-import br.ufrgs.inf.prosoft.adaptivecaching.analysis.decision.flowchart.stats.Stats;
+import br.ufrgs.inf.prosoft.adaptivecaching.analysis.decision.flowchart.stats.Metrics;
 import br.ufrgs.inf.prosoft.adaptivecaching.analysis.decision.flowchart.stats.Thresholds;
 import java.util.ArrayList;
 import java.util.List;
@@ -17,18 +17,18 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
  */
 public class GroupOfOccurrences {
 
-    private final Stats stats;
+    private final Metrics metrics;
     private final List<Occurrence> occurrences;
     private final String parameters;
 
     public GroupOfOccurrences(String parameters) {
         this.parameters = parameters;
-        this.stats = new Stats();
+        this.metrics = new Metrics();
         this.occurrences = new ArrayList<>();
     }
 
-    public Stats getStats() {
-        return stats;
+    public Metrics getMetrics() {
+        return metrics;
     }
 
     public void addOccurrence(Occurrence occurrence) {
@@ -43,9 +43,9 @@ public class GroupOfOccurrences {
         return this.occurrences.size();
     }
 
-    protected void countStats() {
+    protected void calculateMetrics() {
         if (this.occurrences.size() == 1) {
-            this.stats.addSameOccurrence(this.occurrences.get(0));
+            this.metrics.addSameOccurrence(this.occurrences.get(0));
             return;
         }
         for (int i = 0; i < this.occurrences.size(); i++) {
@@ -54,29 +54,29 @@ public class GroupOfOccurrences {
             for (int j = i + 1; j < this.occurrences.size(); j++) {
                 Occurrence other = this.occurrences.get(j);
                 if (EqualsBuilder.reflectionEquals(returnValue, other.getReturnValue())) {
-                    this.stats.addSameOccurrence(occurrence);
+                    this.metrics.addSameOccurrence(occurrence);
                     continue;
                 }
-                this.stats.addDifferentReturnOccurrence();
+                this.metrics.addDifferentReturnOccurrence();
             }
         }
     }
 
     protected void calculateThresholds() {
-        Thresholds.sumExecutionTime += this.stats.getSameOccurrencesTotalExecutionTime();
-        Thresholds.executionTimes.add(this.stats.getSameOccurrencesTotalExecutionTime());
+        Thresholds.sumExecutionTime += this.metrics.getSameOccurrencesTotalExecutionTime();
+        Thresholds.executionTimes.add(this.metrics.getSameOccurrencesTotalExecutionTime());
 
-        Thresholds.sumHitRatio += this.stats.getHitRatio();
-        Thresholds.hitRatios.add(this.stats.getHitRatio());
+        Thresholds.sumHitRatio += this.metrics.getHitRatio();
+        Thresholds.hitRatios.add(this.metrics.getHitRatio());
 
-        Thresholds.sumMissRatio += this.stats.getMissRatio();
-        Thresholds.missRatios.add(this.stats.getMissRatio());
+        Thresholds.sumMissRatio += this.metrics.getMissRatio();
+        Thresholds.missRatios.add(this.metrics.getMissRatio());
 
-        Thresholds.sumShareability += this.stats.getShareability();
-        Thresholds.shareabilities.add(this.stats.getShareability());
+        Thresholds.sumShareability += this.metrics.getShareability();
+        Thresholds.shareabilities.add(this.metrics.getShareability());
 
-        Thresholds.sumFrequency += this.stats.getNumberOfSameOccurrences();
-        Thresholds.frequencies.add(this.stats.getNumberOfSameOccurrences());
+        Thresholds.sumFrequency += this.metrics.getNumberOfSameOccurrences();
+        Thresholds.frequencies.add(this.metrics.getNumberOfSameOccurrences());
     }
 
 }
diff --git a/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/Method.java b/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/Method.java
index 2f174ba..9132058 100644
--- a/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/Method.java
+++ b/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/Method.java
@@ -61,10 +61,13 @@ public class Method {
 
             @Override
             public void accept(Occurrence occurrence) {
-                System.out.print(".");
-                System.out.flush();
-                if (++i % 100 == 0) {
-                    System.out.println();
+                String verbose = System.getenv("TRACER_VERBOSE");
+                if (verbose != null && verbose.equals("true")) {
+                    System.out.print(".");
+                    System.out.flush();
+                    if (++i % 100 == 0) {
+                        System.out.println();
+                    }
                 }
                 String parameters = Arrays.toString(occurrence.getParameters());
                 synchronized (groupByParameter) {
@@ -83,10 +86,10 @@ public class Method {
         this.occurrences.clear();
     }
 
-    public void countStats() {
+    public void calculateMetrics() {
         groupByParameter();
         Collections.sort(this.groupsOfOccurrences, (g1, g2) -> Integer.compare(g1.getOccurrencesSize(), g2.getOccurrencesSize()));
-        this.groupsOfOccurrences.stream().parallel().forEach(GroupOfOccurrences::countStats);
+        this.groupsOfOccurrences.stream().parallel().forEach(GroupOfOccurrences::calculateMetrics);
     }
 
     public void calculateThresholds() {
@@ -102,4 +105,9 @@ public class Method {
             }
         }
     }
+
+    @Override
+    public String toString() {
+        return this.name;
+    }
 }
diff --git a/src/main/java/br/ufrgs/inf/prosoft/approachescomparison/adapter/Main.java b/src/main/java/br/ufrgs/inf/prosoft/approachescomparison/adapter/Main.java
index 2f29ee8..461236a 100644
--- a/src/main/java/br/ufrgs/inf/prosoft/approachescomparison/adapter/Main.java
+++ b/src/main/java/br/ufrgs/inf/prosoft/approachescomparison/adapter/Main.java
@@ -18,31 +18,32 @@ import java.util.logging.Logger;
  */
 public class Main {
 
-    private static final Logger logger = Logger.getLogger(Main.class.getName());
+    private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
 
     public static void main(String[] args) {
         System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT+%1$tL] [%4$-7s] [APLCache] %5$s %n");
 
-        String path = null;
         if (args.length < 1) {
-            System.err.println("No path provided");
+            System.err.println("<TracePath>");
             System.exit(1);
-        } else {
-            path = args[0];
         }
-        logger.log(Level.INFO, "Reading traces");
-        List<Trace> traces = TraceReader.partiallyParseFile(path);
-        logger.log(Level.INFO, "Grouping by methods");
+        String path = args[0];
+        LOGGER.log(Level.INFO, "Reading traces");
+        List<Trace> traces = TraceReader.parseFile(path);
+        LOGGER.log(Level.INFO, "Grouping {0} traces by methods", traces.size());
         List<Method> methods = TraceReader.groupByMethods(traces);
         FlowchartWorkFlow flowchartWorkFlow = new FlowchartWorkFlow();
         flowchartWorkFlow.setMethods(methods);
-        logger.log(Level.INFO, "Filtering cacheable methods");
+        LOGGER.log(Level.INFO, "Filtering cacheable methods");
         flowchartWorkFlow.filterCacheableInputs();
         methods.forEach(method -> {
+            System.out.println(method + " : " + method.getGroupsOfOccurrences().size() + " parameters");
+        });
+        methods.forEach(method -> {
             System.out.println(method);
             method.getGroupsOfOccurrences().forEach(group -> {
                 System.out.println("parameters: " + group.getParameters());
-                System.out.println("stats: " + group.getStats());
+                System.out.println("stats: " + group.getMetrics());
                 System.out.println();
             });
             System.out.println();