This commit is contained in:
Casper V. Kristensen 2019-12-03 14:10:49 +01:00
parent 059387bbd6
commit d4e33c0098
2 changed files with 18 additions and 21 deletions

View File

@ -20,7 +20,7 @@ public class Driver {
} }
EvenSimplerClient client = new EvenSimplerClient(settings, servers, profiler); EvenSimplerClient client = new EvenSimplerClient(settings, servers, profiler);
profiler.start(); profiler.start();
client.receiveBits(1); client.receiveBits(0);
profiler.stop(); profiler.stop();
} }
@ -31,7 +31,7 @@ public class Driver {
} }
SimpleClient client = new SimpleClient(settings, servers, profiler); SimpleClient client = new SimpleClient(settings, servers, profiler);
profiler.start(); profiler.start();
client.receiveBit(1); client.receiveBit(0);
profiler.stop(); profiler.stop();
} }
@ -42,7 +42,7 @@ public class Driver {
} }
SimpleClient client = new SimpleClient(settings, servers, profiler); SimpleClient client = new SimpleClient(settings, servers, profiler);
profiler.start(); profiler.start();
client.receiveBits(1); client.receiveBits(0);
profiler.stop(); profiler.stop();
} }
@ -53,7 +53,7 @@ public class Driver {
} }
InterPolyClient client = new InterPolyClient(settings, servers, profiler); InterPolyClient client = new InterPolyClient(settings, servers, profiler);
profiler.start(); profiler.start();
client.receive(1); client.receive(0);
profiler.stop(); profiler.stop();
} }
@ -64,17 +64,19 @@ public class Driver {
} }
InterPolyClient client = new InterPolyClient(settings, servers, profiler); InterPolyClient client = new InterPolyClient(settings, servers, profiler);
profiler.start(); profiler.start();
client.receiveBlock(1); client.receiveBlock(0);
profiler.stop(); profiler.stop();
} }
public static void runTests() { private static void runTests() {
for (int numServers = 1; numServers <= 8; numServers = numServers*2) { for (int numServers = 1; numServers <= 16; numServers = numServers*2) {
for (int databaseSize = 2; databaseSize <= 4096; databaseSize = databaseSize*2) { for (int databaseSize = 2048; databaseSize <= 32_768; databaseSize = databaseSize*2) {
for (int blockSize = 1; blockSize <= Math.min(512, databaseSize); blockSize = blockSize*2) { for (int blockSize = 64; blockSize <= 16_384; blockSize = blockSize*2) {
for (int latency = 0; latency <= 50; latency = latency + 10) { for (int latency = 0; latency <= 500; latency = latency + 50) {
for (int bandwidth = 1024; bandwidth <= 2048; bandwidth = bandwidth*2) { for (int bandwidth = 64; bandwidth <= 16_384; bandwidth = bandwidth*2) { // in kbit/s
runTest(numServers, databaseSize, blockSize, latency, bandwidth); for (int i = 0; i < 5; i++) {
runTest(numServers, databaseSize, blockSize, latency, bandwidth);
}
} }
} }
} }
@ -82,8 +84,8 @@ public class Driver {
} }
} }
public static void runTest(int numServers, int databaseSize, int blockSize, int latency, int bandwidth) { private static void runTest(int numServers, int databaseSize, int blockSize, int latency, int bandwidth) {
PIRSettings settings = new PIRSettings(databaseSize, numServers, blockSize); PIRSettings settings = new PIRSettings(databaseSize*blockSize, numServers, blockSize);
int[] x = new int[databaseSize]; int[] x = new int[databaseSize];
for (int i = 0; i < x.length; i++) { for (int i = 0; i < x.length; i++) {
x[i] = (int) (Math.random()*2); // 0 or 1 x[i] = (int) (Math.random()*2); // 0 or 1
@ -95,7 +97,6 @@ public class Driver {
testEvenSimplerScheme(settings, database, profiler); testEvenSimplerScheme(settings, database, profiler);
reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "EvenSimplerScheme"); reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "EvenSimplerScheme");
if (numServers == 2) { if (numServers == 2) {
profiler.reset(); profiler.reset();
testSimpleScheme(settings, database, profiler); testSimpleScheme(settings, database, profiler);
@ -117,7 +118,7 @@ public class Driver {
} }
} }
public static void reportResult(int numServers, int databaseSize, int blockSize, int latency, int bandwidth, Profiler profiler, String protocolName) { private static void reportResult(int numServers, int databaseSize, int blockSize, int latency, int bandwidth, Profiler profiler, String protocolName) {
System.out.println( System.out.println(
numServers + " " + numServers + " " +
databaseSize + " " + databaseSize + " " +
@ -128,14 +129,11 @@ public class Driver {
profiler.getTotalCPUTime() + " " + profiler.getTotalCPUTime() + " " +
profiler.getSent() + " " + profiler.getSent() + " " +
profiler.getReceived() + " " + profiler.getReceived() + " " +
profiler.getTotalNetworkTime() + " " profiler.getTotalNetworkTime()
); );
} }
public static void main(String[] args) { public static void main(String[] args) {
runTests(); // warm-up
System.out.println("================");
runTests(); runTests();
} }
} }

View File

@ -23,7 +23,6 @@ public class PIRSettings {
this.s = calculateS(numServers, databaseSize); this.s = calculateS(numServers, databaseSize);
this.sequences = ProtocolUtils.createSequences(s, numServers, databaseSize); this.sequences = ProtocolUtils.createSequences(s, numServers, databaseSize);
} catch (IllegalArgumentException error) { } catch (IllegalArgumentException error) {
System.out.println("pls");
this.s = 0; this.s = 0;
} }