Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for configurable fractional percentile metrics in output file... #863

Merged
merged 1 commit into from
Nov 18, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class OneMeasurementHdrHistogram extends OneMeasurement {
*/
public static final String PERCENTILES_PROPERTY_DEFAULT = "95,99";

List<Integer> percentiles;
List<Double> percentiles;

public OneMeasurementHdrHistogram(String name, Properties props) {
super(name);
Expand Down Expand Up @@ -114,7 +114,7 @@ public void exportMeasurements(MeasurementsExporter exporter) throws IOException
exporter.write(getName(), "MinLatency(us)", totalHistogram.getMinValue());
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));
}

Expand Down Expand Up @@ -162,12 +162,12 @@ private Histogram getIntervalHistogramAndAccumulate() {
* @param percentileString - comma delimited string of Integer values
* @return An Integer List of percentile values
*/
private List<Integer> getPercentileValues(String percentileString) {
List<Integer> percentileValues = new ArrayList<Integer>();
private List<Double> getPercentileValues(String percentileString) {
List<Double> percentileValues = new ArrayList<Double>();

try {
for (String rawPercentile: percentileString.split(",")) {
percentileValues.add(Integer.parseInt(rawPercentile));
percentileValues.add(Double.parseDouble(rawPercentile));
}
} catch(Exception e) {
// If the given hdrhistogram.percentiles value is unreadable for whatever reason,
Expand All @@ -186,15 +186,23 @@ private List<Integer> getPercentileValues(String percentileString) {
* @param i
* @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" };
switch (i % 100) {
case 11:
case 12:
case 13:
return i + "th";
default:
return i + suffixes[i % 10];
Integer j = i.intValue();
if (i%1 == 0)
{
switch (j % 100) {
case 11:
case 12:
case 13:
return j + "th";
default:
return j + suffixes[j % 10];
}
}
else
{
return i.toString();
}
}
}