mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-24 19:22:18 +00:00
Statistician
- Changed over to using nanoseconds instead of milliseconds -- Better Accuracy -- milliseconds is not always properly measured
This commit is contained in:
parent
095738dcbc
commit
92ce527c0c
@ -273,10 +273,10 @@ public class KademliaNode
|
||||
* */
|
||||
public synchronized final void bootstrap(Node n) throws IOException, RoutingException
|
||||
{
|
||||
long startTime = System.currentTimeMillis() / 1000L;
|
||||
long startTime = System.nanoTime();
|
||||
Operation op = new ConnectOperation(this.server, this, n, this.config);
|
||||
op.execute();
|
||||
long endTime = System.currentTimeMillis() / 1000L;
|
||||
long endTime = System.nanoTime();
|
||||
this.statistician.setBootstrapTime(endTime - startTime);
|
||||
}
|
||||
|
||||
@ -324,11 +324,11 @@ public class KademliaNode
|
||||
*/
|
||||
public StorageEntry get(GetParameter param) throws NoSuchElementException, IOException, ContentNotFoundException
|
||||
{
|
||||
long startTime = System.currentTimeMillis() / 1000L;
|
||||
long startTime = System.nanoTime();
|
||||
if (this.dht.contains(param))
|
||||
{
|
||||
/* If the content exist in our own DHT, then return it. */
|
||||
long endTime = System.currentTimeMillis() / 1000L;
|
||||
long endTime = System.nanoTime();
|
||||
this.statistician.addContentLookupTime(endTime - startTime);
|
||||
return this.dht.get(param);
|
||||
}
|
||||
@ -336,7 +336,7 @@ public class KademliaNode
|
||||
/* Seems like it doesn't exist in our DHT, get it from other Nodes */
|
||||
ContentLookupOperation clo = new ContentLookupOperation(server, this, param, this.config);
|
||||
clo.execute();
|
||||
long endTime = System.currentTimeMillis() / 1000L;
|
||||
long endTime = System.nanoTime();
|
||||
this.statistician.addContentLookupTime(endTime - startTime);
|
||||
return clo.getContentFound();
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class Statistician
|
||||
/**
|
||||
* Sets the bootstrap time for this Kademlia Node
|
||||
*
|
||||
* @param time The bootstrap time in milliseconds
|
||||
* @param time The bootstrap time in nanoseconds
|
||||
*/
|
||||
public void setBootstrapTime(long time)
|
||||
{
|
||||
@ -84,7 +84,7 @@ public class Statistician
|
||||
/**
|
||||
* Add the timing for a new content lookup operation that took place
|
||||
*
|
||||
* @param time The time the content lookup took in milliseconds
|
||||
* @param time The time the content lookup took in nanoseconds
|
||||
*/
|
||||
public void addContentLookupTime(long time)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user