Skip to content

Commit

Permalink
Improve test logging for ipns benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ianopolous committed Dec 11, 2023
1 parent aec72ef commit 71be5c4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/test/java/org/peergos/KademliaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ public void ipnsBenchmark() throws Exception {
long p0 = System.currentTimeMillis();
dht1.publishIpnsValue(signer, pub, value, 1, node1).join();
long p1 = System.currentTimeMillis();
System.out.println("Publish took " + (p1-p0) + "ms");
System.out.println("Publish took " + printSeconds(p1-p0) + "s");
publishTotal += p1-p0;

// retrieve it from node 2
long t0 = System.currentTimeMillis();
String res = dht2.resolveIpnsValue(pub, node2, 1).orTimeout(10, TimeUnit.SECONDS).join();
long t1 = System.currentTimeMillis();
Assert.assertTrue(res.equals("/ipfs/" + value));
System.out.println("Resolved in " + (t1 - t0) + "ms");
System.out.println("Resolved in " + printSeconds(t1 - t0) + "s");
resolveTotal += t1-t0;
}
System.out.println("Publish av: " + publishTotal/iterations + ", resolve av: " + resolveTotal/iterations);
Expand All @@ -116,14 +116,18 @@ public void ipnsBenchmark() throws Exception {
String res = dht2.resolveIpnsValue(pub, node2, 1).orTimeout(10, TimeUnit.SECONDS).join();
long t1 = System.currentTimeMillis();
Assert.assertTrue(res.equals("/ipfs/" + value));
System.out.println("Resolved again in " + (t1 - t0) + "ms");
System.out.println("Resolved again in " + printSeconds(t1 - t0) + "s");
}
} finally {
node1.stop();
node2.stop();
}
}

public static String printSeconds(long millis) {
return millis / 1000 + "." + (millis % 1000)/100;
}

@Test
public void kademliaFindNodeLimitTest() {
PeerId us = new HostBuilder().generateIdentity().getPeerId();
Expand Down

0 comments on commit 71be5c4

Please sign in to comment.