Browse Source

small changes

Boyoung- 9 years ago
parent
commit
e2b113a211
4 changed files with 10 additions and 30 deletions
  1. 7 4
      src/protocols/Retrieve.java
  2. 3 4
      src/util/Bandwidth.java
  3. 0 13
      src/util/StopWatch.java
  4. 0 9
      src/util/Timer.java

+ 7 - 4
src/protocols/Retrieve.java

@@ -184,6 +184,9 @@ public class Retrieve extends Protocol {
 
 
 		long[] gates = new long[2];
 		long[] gates = new long[2];
 
 
+		PreData[][] predata = new PreData[numTrees][2];
+		PreRetrieve preretrieve = new PreRetrieve(con1, con2);
+
 		Pipeline[] threads = new Pipeline[numTrees];
 		Pipeline[] threads = new Pipeline[numTrees];
 
 
 		sanityCheck();
 		sanityCheck();
@@ -211,8 +214,6 @@ public class Retrieve extends Protocol {
 				System.out.println("N=" + BigInteger.valueOf(N).toString(2));
 				System.out.println("N=" + BigInteger.valueOf(N).toString(2));
 
 
 				System.out.print("Precomputation... ");
 				System.out.print("Precomputation... ");
-				PreData[][] predata = new PreData[numTrees][2];
-				PreRetrieve preretrieve = new PreRetrieve(con1, con2);
 				for (int ti = 0; ti < numTrees; ti++) {
 				for (int ti = 0; ti < numTrees; ti++) {
 					predata[ti][0] = new PreData();
 					predata[ti][0] = new PreData();
 					predata[ti][1] = new PreData();
 					predata[ti][1] = new PreData();
@@ -359,8 +360,10 @@ public class Retrieve extends Protocol {
 		Bandwidth[] bandwidth = new Bandwidth[P.size];
 		Bandwidth[] bandwidth = new Bandwidth[P.size];
 		for (int i = 0; i < P.size; i++) {
 		for (int i = 0; i < P.size; i++) {
 			bandwidth[i] = new Bandwidth(P.names[i]);
 			bandwidth[i] = new Bandwidth(P.names[i]);
-			for (int j = 0; j < cons1.length; j++)
-				bandwidth[i] = bandwidth[i].add(cons1[j].bandwidth[i].add(cons2[j].bandwidth[i]));
+			for (int j = 0; j < cons1.length; j++) {
+				bandwidth[i].add(cons1[j].bandwidth[i]);
+				bandwidth[i].add(cons2[j].bandwidth[i]);
+			}
 			System.out.println(bandwidth[i].noPreToString());
 			System.out.println(bandwidth[i].noPreToString());
 		}
 		}
 		System.out.println();
 		System.out.println();

+ 3 - 4
src/util/Bandwidth.java

@@ -25,12 +25,11 @@ public class Bandwidth {
 		bandwidth += n;
 		bandwidth += n;
 	}
 	}
 
 
-	public Bandwidth add(Bandwidth b) {
+	public void add(Bandwidth b) {
 		if (!task.equals(b.task))
 		if (!task.equals(b.task))
 			throw new BandwidthException("Task: " + task + " != " + b.task);
 			throw new BandwidthException("Task: " + task + " != " + b.task);
-		Bandwidth total = new Bandwidth(task);
-		total.bandwidth = bandwidth + b.bandwidth;
-		return total;
+
+		bandwidth = bandwidth + b.bandwidth;
 	}
 	}
 
 
 	public String noPreToString() {
 	public String noPreToString() {

+ 0 - 13
src/util/StopWatch.java

@@ -108,19 +108,6 @@ public class StopWatch {
 		return sw;
 		return sw;
 	}
 	}
 
 
-	/*
-	 * public StopWatch add(StopWatch s) { if (isOn || s.isOn) { try { throw new
-	 * StopWatchException("StopWatch is still running"); } catch
-	 * (StopWatchException e) { e.printStackTrace(); } }
-	 * 
-	 * if (!task.equals(s.task)) { try { throw new StopWatchException(
-	 * "Tasks don't match: " + task + " != " + s.task); } catch
-	 * (StopWatchException e) { e.printStackTrace(); } }
-	 * 
-	 * StopWatch sw = new StopWatch(task); sw.elapsedWC = elapsedWC +
-	 * s.elapsedWC; sw.elapsedCPU = elapsedCPU + s.elapsedCPU; return sw; }
-	 */
-
 	public void add(StopWatch s) {
 	public void add(StopWatch s) {
 		if (isOn || s.isOn) {
 		if (isOn || s.isOn) {
 			try {
 			try {

+ 0 - 9
src/util/Timer.java

@@ -74,15 +74,6 @@ public class Timer {
 		return new Timer(sws);
 		return new Timer(sws);
 	}
 	}
 
 
-	/*
-	 * public Timer add(Timer t) { if (!stack.empty() || !t.stack.empty()) throw
-	 * new TimerException("Stack not empty");
-	 * 
-	 * StopWatch[][] sws = new StopWatch[P.size][M.size]; for (int i = 0; i <
-	 * watches.length; i++) for (int j = 0; j < watches[i].length; j++)
-	 * sws[i][j] = watches[i][j].add(t.watches[i][j]); return new Timer(sws); }
-	 */
-
 	public void add(Timer t) {
 	public void add(Timer t) {
 		if (!stack.empty() || !t.stack.empty())
 		if (!stack.empty() || !t.stack.empty())
 			throw new TimerException("Stack not empty");
 			throw new TimerException("Stack not empty");