Statistician

- Changed over to using nanoseconds instead of milliseconds
-- Better Accuracy
-- milliseconds is not always properly measured
This commit is contained in:
Joshua Kissoon 2014-05-07 00:54:55 +05:30
parent 095738dcbc
commit 92ce527c0c
2 changed files with 7 additions and 7 deletions

View File

@ -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();
}

View File

@ -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)
{