aplcache
Changes
pom.xml 5(+0 -5)
src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/analysis/decision/flowchart/FlowchartWorkFlow.java 8(+5 -3)
src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/GroupOfOccurrences.java 9(+6 -3)
src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/Method.java 10(+6 -4)
Details
pom.xml 5(+0 -5)
diff --git a/pom.xml b/pom.xml
index ab23205..5bb508d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,11 +16,6 @@
<dependencies>
<dependency>
- <groupId>org.ehcache</groupId>
- <artifactId>sizeof</artifactId>
- <version>0.3.0</version>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
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 497dc70..738cc0b 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
@@ -2,8 +2,9 @@ package br.ufrgs.inf.prosoft.adaptivecaching.analysis.decision.flowchart;
import br.ufrgs.inf.prosoft.adaptivecaching.analysis.decision.flowchart.stats.Thresholds;
import br.ufrgs.inf.prosoft.adaptivecaching.monitoring.application.metadata.Method;
-import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -11,15 +12,16 @@ public final class FlowchartWorkFlow {
private static final Logger logger = Logger.getLogger(FlowchartWorkFlow.class.getName());
- private Collection<Method> methods;
+ private List<Method> methods;
- public FlowchartWorkFlow setMethods(Collection<Method> methods) {
+ public FlowchartWorkFlow setMethods(List<Method> methods) {
this.methods = methods;
return this;
}
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);
}
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 8682038..c229a9a 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
@@ -33,6 +33,10 @@ public class GroupOfOccurrences {
this.occurrences.add(occurrence);
}
+ public int getOccurrencesSize() {
+ return this.occurrences.size();
+ }
+
protected void countStats() {
if (this.occurrences.size() == 1) {
this.stats.addSameOccurrence(this.occurrences.get(0));
@@ -40,16 +44,15 @@ public class GroupOfOccurrences {
}
for (int i = 0; i < this.occurrences.size(); i++) {
Occurrence occurrence = this.occurrences.get(i);
-// load concrete
+ Object returnValue = occurrence.getReturnValue();
for (int j = i + 1; j < this.occurrences.size(); j++) {
Occurrence other = this.occurrences.get(j);
- if (EqualsBuilder.reflectionEquals(occurrence.getReturnValue(), other.getReturnValue())) {
+ if (EqualsBuilder.reflectionEquals(returnValue, other.getReturnValue())) {
this.stats.addSameOccurrence(occurrence);
continue;
}
this.stats.addDifferentReturnOccurrence();
}
-// remove
}
}
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 e6fe5cb..6314862 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
@@ -8,7 +8,7 @@ package br.ufrgs.inf.prosoft.adaptivecaching.monitoring.application.metadata;
import br.ufrgs.inf.prosoft.adaptivecaching.analysis.decision.flowchart.stats.CacheabilityPatternDecider;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -16,6 +16,7 @@ import java.util.Map;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.stream.Collectors;
/**
*
@@ -27,7 +28,7 @@ public class Method {
private final String name;
private final List<Occurrence> occurrences;
- private Collection<GroupOfOccurrences> groupsOfOccurrences;
+ private List<GroupOfOccurrences> groupsOfOccurrences;
public Method(String name) {
this.name = name;
@@ -48,7 +49,7 @@ public class Method {
return this.occurrences.size();
}
- public Collection<GroupOfOccurrences> getGroupsOfOccurrences() {
+ public List<GroupOfOccurrences> getGroupsOfOccurrences() {
return groupsOfOccurrences;
}
@@ -77,13 +78,14 @@ public class Method {
}
}
});
- this.groupsOfOccurrences = groupByParameter.values();
+ this.groupsOfOccurrences = groupByParameter.values().stream().collect(Collectors.toList());
groupByParameter.clear();
this.occurrences.clear();
}
public void countStats() {
groupByParameter();
+ Collections.sort(this.groupsOfOccurrences, (g1, g2) -> Integer.compare(g1.getOccurrencesSize(), g2.getOccurrencesSize()));
this.groupsOfOccurrences.stream().parallel().forEach(GroupOfOccurrences::countStats);
}
diff --git a/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/Occurrence.java b/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/Occurrence.java
index 241d94b..de17d17 100644
--- a/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/Occurrence.java
+++ b/src/main/java/br/ufrgs/inf/prosoft/adaptivecaching/monitoring/application/metadata/Occurrence.java
@@ -1,9 +1,5 @@
package br.ufrgs.inf.prosoft.adaptivecaching.monitoring.application.metadata;
-import java.util.Objects;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.ehcache.sizeof.SizeOf;
-
public abstract class Occurrence {
private final long startTime;
@@ -28,67 +24,4 @@ public abstract class Occurrence {
public abstract Object getReturnValue();
- public long getSizeOfReturnedValue() {
- SizeOf sizeOf = SizeOf.newInstance();
- return sizeOf.sizeOf(getReturnValue());
- }
-
- @Deprecated
- public boolean equalsWithoutReturnedValue(Occurrence o) {
- System.out.println("DEPRECATED");
-
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- Object[] thisArguments = getParameters();
- Object[] otherArguments = o.getParameters();
- return Objects.deepEquals(thisArguments, otherArguments)
- || EqualsBuilder.reflectionEquals(thisArguments, otherArguments);
- }
-
- @Override
- @Deprecated
- public int hashCode() {
- System.out.println("DEPRECATED");
- int result = (int) (startTime ^ (startTime >>> 32));
- result = 31 * result + (int) (endTime ^ (endTime >>> 32));
- result = 31 * result + (userId != null ? userId.hashCode() : 0);
- return result;
- }
-
- @Override
- @Deprecated
- public boolean equals(Object o) {
- System.out.println("DEPRECATED");
- if (this == o) {
- return true;
- }
- if (!(o instanceof Occurrence)) {
- return false;
- }
- Occurrence logTrace = (Occurrence) o;
- if (endTime != logTrace.endTime) {
- return false;
- }
- if (startTime != logTrace.startTime) {
- return false;
- }
- if (userId != null ? !userId.equals(logTrace.userId) : logTrace.userId != null) {
- return false;
- }
- Object[] thisArguments = getParameters();
- Object[] thatArguments = logTrace.getParameters();
- if (!EqualsBuilder.reflectionEquals(thisArguments, thatArguments)) {
- return false;
- }
- thisArguments = null;
- thatArguments = null;
- Object thisReturnedValue = getReturnValue();
- Object thatReturnedValue = logTrace.getReturnValue();
- return EqualsBuilder.reflectionEquals(thisReturnedValue, thatReturnedValue)
- || Objects.deepEquals(thisReturnedValue, thatReturnedValue);
- }
}
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 8d9e7d9..13bfe64 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
@@ -8,7 +8,6 @@ package br.ufrgs.inf.prosoft.approachescomparison.adapter;
import br.ufrgs.inf.prosoft.adaptivecaching.analysis.decision.flowchart.FlowchartWorkFlow;
import br.ufrgs.inf.prosoft.adaptivecaching.monitoring.application.metadata.Method;
import br.ufrgs.inf.prosoft.trace.Trace;
-import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -34,7 +33,7 @@ public class Main {
logger.log(Level.INFO, "Reading traces");
List<Trace> traces = TraceReader.partiallyParseFile(path);
logger.log(Level.INFO, "Grouping by methods");
- Collection<Method> methods = TraceReader.groupByMethods(traces);
+ List<Method> methods = TraceReader.groupByMethods(traces);
FlowchartWorkFlow flowchartWorkFlow = new FlowchartWorkFlow();
flowchartWorkFlow.setMethods(methods);
logger.log(Level.INFO, "Filtering cacheable methods");
diff --git a/src/main/java/br/ufrgs/inf/prosoft/approachescomparison/adapter/TraceReader.java b/src/main/java/br/ufrgs/inf/prosoft/approachescomparison/adapter/TraceReader.java
index 4a018cd..3a69f23 100644
--- a/src/main/java/br/ufrgs/inf/prosoft/approachescomparison/adapter/TraceReader.java
+++ b/src/main/java/br/ufrgs/inf/prosoft/approachescomparison/adapter/TraceReader.java
@@ -12,7 +12,6 @@ import br.ufrgs.inf.prosoft.adaptivecaching.monitoring.application.metadata.Meth
import br.ufrgs.inf.prosoft.trace.Parameter;
import br.ufrgs.inf.prosoft.trace.Trace;
import br.ufrgs.inf.prosoft.trace.TraceReference;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -28,7 +27,7 @@ public class TraceReader extends br.ufrgs.inf.prosoft.trace.reader.TraceReader {
private static final Logger logger = Logger.getLogger(TraceReader.class.getName());
- public static Collection<Method> groupByMethods(List<Trace> traces) {
+ public static List<Method> groupByMethods(List<Trace> traces) {
Map<String, Method> methodNameHasOccurrences = new HashMap<>();
while (!traces.isEmpty()) {
Trace trace = traces.remove(0);
@@ -60,6 +59,6 @@ public class TraceReader extends br.ufrgs.inf.prosoft.trace.reader.TraceReader {
logger.log(Level.INFO, "Trace discarted: {0}", trace);
}
}
- return methodNameHasOccurrences.values();
+ return methodNameHasOccurrences.values().stream().collect(Collectors.toList());
}
}