Commit 5eb11da8 authored by  Rewaj  Shrestha's avatar Rewaj Shrestha

rs6017: Prints miss rate

parent 5d013675
......@@ -5,7 +5,7 @@ import java.util.List;
public class Main {
public static void main(String[] args) {
Simulation.run(2, 3 ,200000.0, 10, 1000.0, EvictionPolicy.FIFO , 95, true);
Simulation.run(2, 3 ,200000.0, 10, 1000.0, EvictionPolicy.RAND , 95, true);
}
......
......@@ -24,12 +24,13 @@ public class Simulation {
stateToTime.put(cache, stateToTime.get(cache) + nextArrivalTime);
}
// System.out.println("Miss ratio is " + (double) misses/requests);
currentTime += nextArrivalTime;
int item = getItem();
processItemRequest(item);
}
}
......@@ -73,6 +74,7 @@ public class Simulation {
double confidence, boolean printStates) {
Measure missesMeasure = new Measure();
Measure missRate = new Measure();
HashMap<List<Integer>, Measure> stateToMeasures = new HashMap<>();
for (int i = 0; i < numberOfSimulations ; i ++) {
Simulation warmUpSimulation = new Simulation(m, n, evictionPolicy);
......@@ -84,6 +86,7 @@ public class Simulation {
missesMeasure.addObservation(((double) recordSimulation.misses) / recordSimulation.requests);
missRate.addObservation(((double) recordSimulation.misses) / simulationTime);
for (List<Integer> state : recordSimulation.stateToTime.keySet()) {
if (!stateToMeasures.containsKey(state)) {
Measure stateMeasure = new Measure();
......@@ -99,7 +102,13 @@ public class Simulation {
double ciRange = missesMeasure.ciHalfWidth(confidence);
double upperVal = mean + ciRange;
double lowerVal = mean - ciRange;
System.out.println("Miss Mean is " + missesMeasure.sampleMean() + " CI is ( " + lowerVal + ", " + upperVal +")");
System.out.println("Miss Mean Ratio is " + missesMeasure.sampleMean() + " CI is ( " + lowerVal + ", " + upperVal +")");
double rateMean = missRate.sampleMean();
double rateCiRange = missRate.ciHalfWidth(confidence);
double rateUpperVal = rateMean + rateCiRange;
double rateLowerVal = rateMean - rateCiRange;
System.out.println("Miss Mean Rate is " + missRate.sampleMean() + " CI is ( " + rateLowerVal + ", " + rateUpperVal +")");
if (printStates) {
for (List<Integer> state : stateToMeasures.keySet()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment