Skip to content
Snippets Groups Projects
Commit 1d37be1f authored by jschmieg's avatar jschmieg Committed by Kevin Risden
Browse files

[core] Support for configurable fractional percentile metrics in output file printout (#863)

parent 1b8ebe4b
No related branches found
No related tags found
No related merge requests found
...@@ -58,7 +58,7 @@ public class OneMeasurementHdrHistogram extends OneMeasurement { ...@@ -58,7 +58,7 @@ public class OneMeasurementHdrHistogram extends OneMeasurement {
*/ */
public static final String PERCENTILES_PROPERTY_DEFAULT = "95,99"; public static final String PERCENTILES_PROPERTY_DEFAULT = "95,99";
List<Integer> percentiles; List<Double> percentiles;
public OneMeasurementHdrHistogram(String name, Properties props) { public OneMeasurementHdrHistogram(String name, Properties props) {
super(name); super(name);
...@@ -114,7 +114,7 @@ public class OneMeasurementHdrHistogram extends OneMeasurement { ...@@ -114,7 +114,7 @@ public class OneMeasurementHdrHistogram extends OneMeasurement {
exporter.write(getName(), "MinLatency(us)", totalHistogram.getMinValue()); exporter.write(getName(), "MinLatency(us)", totalHistogram.getMinValue());
exporter.write(getName(), "MaxLatency(us)", totalHistogram.getMaxValue()); exporter.write(getName(), "MaxLatency(us)", totalHistogram.getMaxValue());
for (Integer percentile: percentiles) { for (Double percentile: percentiles) {
exporter.write(getName(), ordinal(percentile) + "PercentileLatency(us)", totalHistogram.getValueAtPercentile(percentile)); exporter.write(getName(), ordinal(percentile) + "PercentileLatency(us)", totalHistogram.getValueAtPercentile(percentile));
} }
...@@ -162,12 +162,12 @@ public class OneMeasurementHdrHistogram extends OneMeasurement { ...@@ -162,12 +162,12 @@ public class OneMeasurementHdrHistogram extends OneMeasurement {
* @param percentileString - comma delimited string of Integer values * @param percentileString - comma delimited string of Integer values
* @return An Integer List of percentile values * @return An Integer List of percentile values
*/ */
private List<Integer> getPercentileValues(String percentileString) { private List<Double> getPercentileValues(String percentileString) {
List<Integer> percentileValues = new ArrayList<Integer>(); List<Double> percentileValues = new ArrayList<Double>();
try { try {
for (String rawPercentile: percentileString.split(",")) { for (String rawPercentile: percentileString.split(",")) {
percentileValues.add(Integer.parseInt(rawPercentile)); percentileValues.add(Double.parseDouble(rawPercentile));
} }
} catch(Exception e) { } catch(Exception e) {
// If the given hdrhistogram.percentiles value is unreadable for whatever reason, // If the given hdrhistogram.percentiles value is unreadable for whatever reason,
...@@ -186,15 +186,23 @@ public class OneMeasurementHdrHistogram extends OneMeasurement { ...@@ -186,15 +186,23 @@ public class OneMeasurementHdrHistogram extends OneMeasurement {
* @param i * @param i
* @return ordinal string * @return ordinal string
*/ */
private String ordinal(int i) { private String ordinal(Double i) {
String[] suffixes = new String[] { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" }; String[] suffixes = new String[] { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" };
switch (i % 100) { Integer j = i.intValue();
case 11: if (i%1 == 0)
case 12: {
case 13: switch (j % 100) {
return i + "th"; case 11:
default: case 12:
return i + suffixes[i % 10]; case 13:
return j + "th";
default:
return j + suffixes[j % 10];
}
}
else
{
return i.toString();
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment