forked from I2P_Developers/i2p.i2p
more accurate job stats
This commit is contained in:
@@ -1494,11 +1494,11 @@ public class DataHelper {
|
||||
* @since 0.8.2
|
||||
*/
|
||||
public static String formatDuration2(long ms) {
|
||||
if (ms == 0)
|
||||
return "0";
|
||||
String t;
|
||||
long ams = ms >= 0 ? ms : 0 - ms;
|
||||
if (ms == 0) {
|
||||
return "0";
|
||||
} else if (ams < 3 * 1000) {
|
||||
if (ams < 3 * 1000) {
|
||||
// NOTE TO TRANSLATORS: Feel free to translate all these as you see fit, there are several options...
|
||||
// spaces or not, '.' or not, plural or not. Try not to make it too long, it is used in
|
||||
// a lot of tables.
|
||||
@@ -1538,6 +1538,42 @@ public class DataHelper {
|
||||
return t.replace(" ", " ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Like formatDuration2(long) but with microsec and nanosec also.
|
||||
*
|
||||
* @since 0.9.19
|
||||
*/
|
||||
public static String formatDuration2(double ms) {
|
||||
if (ms == 0d)
|
||||
return "0";
|
||||
String t;
|
||||
double adms = ms >= 0 ? ms : 0 - ms;
|
||||
long lms = (long) ms;
|
||||
long ams = lms >= 0 ? lms : 0 - lms;
|
||||
if (adms < 0.000000001d) {
|
||||
return "0";
|
||||
} else if (adms < 0.001d) {
|
||||
t = ngettext("1 ns", "{0,number,###} ns", (int) Math.round(ms * 1000000d));
|
||||
} else if (adms < 1.0d) {
|
||||
t = ngettext("1 μs", "{0,number,###} μs", (int) Math.round(ms * 1000d));
|
||||
} else if (ams < 3 * 1000) {
|
||||
t = ngettext("1 ms", "{0,number,####} ms", (int) Math.round(ms));
|
||||
} else if (ams < 2 * 60 * 1000) {
|
||||
t = ngettext("1 sec", "{0} sec", (int) (ms / 1000));
|
||||
} else if (ams < 120 * 60 * 1000) {
|
||||
t = ngettext("1 min", "{0} min", (int) (ms / (60 * 1000)));
|
||||
} else if (ams < 2 * 24 * 60 * 60 * 1000) {
|
||||
t = ngettext("1 hour", "{0} hours", (int) (ms / (60 * 60 * 1000)));
|
||||
} else if (ams > 1000l * 24l * 60l * 60l * 1000l) {
|
||||
return _("n/a");
|
||||
} else {
|
||||
t = ngettext("1 day", "{0} days", (int) (ms / (24 * 60 * 60 * 1000)));
|
||||
}
|
||||
if (ms < 0)
|
||||
t = t.replace("-", "−");
|
||||
return t.replace(" ", " ");
|
||||
}
|
||||
|
||||
private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
|
||||
|
||||
private static String _(String key) {
|
||||
|
||||
@@ -55,24 +55,27 @@ public class JobStats {
|
||||
public long getTotalTime() { return _totalTime.get(); }
|
||||
public long getMaxTime() { return _maxTime; }
|
||||
public long getMinTime() { return _minTime; }
|
||||
public long getAvgTime() {
|
||||
|
||||
public double getAvgTime() {
|
||||
long numRuns = _numRuns.get();
|
||||
if (numRuns > 0)
|
||||
return _totalTime.get() / numRuns;
|
||||
return _totalTime.get() / (double) numRuns;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
public long getTotalPendingTime() { return _totalPendingTime.get(); }
|
||||
public long getMaxPendingTime() { return _maxPendingTime; }
|
||||
public long getMinPendingTime() { return _minPendingTime; }
|
||||
public long getAvgPendingTime() {
|
||||
|
||||
public double getAvgPendingTime() {
|
||||
long numRuns = _numRuns.get();
|
||||
if (numRuns > 0)
|
||||
return _totalPendingTime.get() / numRuns;
|
||||
return _totalPendingTime.get() / (double) numRuns;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****
|
||||
@Override
|
||||
public int hashCode() { return _job.hashCode(); }
|
||||
|
||||
@@ -100,4 +103,5 @@ public class JobStats {
|
||||
buf.append(getMaxPendingTime()).append("ms/").append(getMinPendingTime()).append("ms avg/max/min)");
|
||||
return buf.toString();
|
||||
}
|
||||
****/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user