mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-22 02:02:21 +00:00
Statistician
- Added some handling for 0 based values
This commit is contained in:
parent
a25b88a9bb
commit
c23edf2cb9
@ -45,6 +45,11 @@ public class Statistician implements KadStatistician
|
|||||||
@Override
|
@Override
|
||||||
public long getTotalDataSent()
|
public long getTotalDataSent()
|
||||||
{
|
{
|
||||||
|
if (this.totalDataSent == 0)
|
||||||
|
{
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
return this.totalDataSent / 1000L;
|
return this.totalDataSent / 1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +63,10 @@ public class Statistician implements KadStatistician
|
|||||||
@Override
|
@Override
|
||||||
public long getTotalDataReceived()
|
public long getTotalDataReceived()
|
||||||
{
|
{
|
||||||
|
if (this.totalDataReceived == 0)
|
||||||
|
{
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
return this.totalDataReceived / 1000L;
|
return this.totalDataReceived / 1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +118,11 @@ public class Statistician implements KadStatistician
|
|||||||
@Override
|
@Override
|
||||||
public double averageContentLookupTime()
|
public double averageContentLookupTime()
|
||||||
{
|
{
|
||||||
|
if (this.numContentLookups == 0)
|
||||||
|
{
|
||||||
|
return 0D;
|
||||||
|
}
|
||||||
|
|
||||||
double avg = (double) ((double) this.totalContentLookupTime / (double) this.numContentLookups) / 1000000D;
|
double avg = (double) ((double) this.totalContentLookupTime / (double) this.numContentLookups) / 1000000D;
|
||||||
DecimalFormat df = new DecimalFormat("#.00");
|
DecimalFormat df = new DecimalFormat("#.00");
|
||||||
return new Double(df.format(avg));
|
return new Double(df.format(avg));
|
||||||
@ -117,6 +131,10 @@ public class Statistician implements KadStatistician
|
|||||||
@Override
|
@Override
|
||||||
public double averageContentLookupRouteLength()
|
public double averageContentLookupRouteLength()
|
||||||
{
|
{
|
||||||
|
if (this.numContentLookups == 0)
|
||||||
|
{
|
||||||
|
return 0D;
|
||||||
|
}
|
||||||
double avg = (double) ((double) this.totalRouteLength / (double) this.numContentLookups);
|
double avg = (double) ((double) this.totalRouteLength / (double) this.numContentLookups);
|
||||||
DecimalFormat df = new DecimalFormat("#.00");
|
DecimalFormat df = new DecimalFormat("#.00");
|
||||||
return new Double(df.format(avg));
|
return new Double(df.format(avg));
|
||||||
|
Loading…
Reference in New Issue
Block a user