Skip to content
This repository was archived by the owner on Aug 23, 2021. It is now read-only.

Standardize metric labels and units #338

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
19 changes: 10 additions & 9 deletions src/com/oltpbenchmark/DistributionStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.apache.log4j.Logger;


public class DistributionStatistics {
private static final Logger LOG = Logger.getLogger(DistributionStatistics.class);

Expand Down Expand Up @@ -165,15 +166,15 @@ public String toString() {

public Map<String, Double> toMap() {
Map<String, Double> distMap = new LinkedHashMap<String, Double>();
distMap.put("Minimum Latency (milliseconds)", getMinimum() / 1e3);
distMap.put("25th Percentile Latency (milliseconds)", get25thPercentile() / 1e3);
distMap.put("Median Latency (milliseconds)", getMedian() / 1e3);
distMap.put("Average Latency (milliseconds)", getAverage() / 1e3);
distMap.put("75th Percentile Latency (milliseconds)", get75thPercentile() / 1e3);
distMap.put("90th Percentile Latency (milliseconds)", get90thPercentile() / 1e3);
distMap.put("95th Percentile Latency (milliseconds)", get95thPercentile() / 1e3);
distMap.put("99th Percentile Latency (milliseconds)", get99thPercentile() / 1e3);
distMap.put("Maximum Latency (milliseconds)", getMaximum() / 1e3);
distMap.put(LatencyRecord.METRIC_LABELS.get("MINIMUM"), getMinimum() / 1e3);
distMap.put(LatencyRecord.METRIC_LABELS.get("25TH_PERCENTILE"), get25thPercentile() / 1e3);
distMap.put(LatencyRecord.METRIC_LABELS.get("MEDIAN"), getMedian() / 1e3);
distMap.put(LatencyRecord.METRIC_LABELS.get("AVERAGE"), getAverage() / 1e3);
distMap.put(LatencyRecord.METRIC_LABELS.get("75TH_PERCENTILE"), get75thPercentile() / 1e3);
distMap.put(LatencyRecord.METRIC_LABELS.get("90TH_PERCENTILE"), get90thPercentile() / 1e3);
distMap.put(LatencyRecord.METRIC_LABELS.get("95TH_PERCENTILE"), get95thPercentile() / 1e3);
distMap.put(LatencyRecord.METRIC_LABELS.get("99TH_PERCENTILE"), get99thPercentile() / 1e3);
distMap.put(LatencyRecord.METRIC_LABELS.get("MAXIMUM"), getMaximum() / 1e3);
return distMap;
}
}
19 changes: 19 additions & 0 deletions src/com/oltpbenchmark/LatencyRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,32 @@
package com.oltpbenchmark;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/** Efficiently stores a record of (start time, latency) pairs. */
public class LatencyRecord implements Iterable<LatencyRecord.Sample> {
/** Allocate space for 500k samples at a time */
static final int ALLOC_SIZE = 500000;

/** Labels for latency metrics */
public static Map<String, String> METRIC_LABELS;
static{
METRIC_LABELS = new HashMap<>();
METRIC_LABELS.put("MINIMUM","Minimum Latency (milliseconds)");
METRIC_LABELS.put("25TH_PERCENTILE","25th Percentile Latency (milliseconds)");
METRIC_LABELS.put("MEDIAN","Median Latency (milliseconds)");
METRIC_LABELS.put("AVERAGE","Average Latency (milliseconds)");
METRIC_LABELS.put("75TH_PERCENTILE","75th Percentile Latency (milliseconds)");
METRIC_LABELS.put("90TH_PERCENTILE","90th Percentile Latency (milliseconds)");
METRIC_LABELS.put("95TH_PERCENTILE","95th Percentile Latency (milliseconds)");
METRIC_LABELS.put("99TH_PERCENTILE","99th Percentile Latency (milliseconds)");
METRIC_LABELS.put("MAXIMUM","Maximum Latency (milliseconds)");


}

/**
* Contains (start time, latency, transactionType, workerid, phaseid) pentiplets
* in microsecond form. The start times are "compressed" by encoding them as
Expand Down
59 changes: 37 additions & 22 deletions src/com/oltpbenchmark/Results.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public final class Results {
final Histogram<TransactionType> txnRetry = new Histogram<TransactionType>(true);
final Histogram<TransactionType> txnErrors = new Histogram<TransactionType>(true);
final Map<TransactionType, Histogram<String>> txnAbortMessages = new HashMap<TransactionType, Histogram<String>>();
final double MILLISECONDS_FACTOR = 1e3;
/** Metrics labels */
final String TIME_LABEL = "Time (seconds)";
final String THROUGHPUT_LABEL = "Throughput (requests/second)";

public final List<LatencyRecord.Sample> latencySamples;

Expand Down Expand Up @@ -90,10 +94,21 @@ public void writeCSV(int windowSizeSeconds, PrintStream out) {
}

public void writeCSV(int windowSizeSeconds, PrintStream out, TransactionType txType) {
out.println("time(sec), throughput(req/sec), avg_lat(ms), min_lat(ms), 25th_lat(ms), median_lat(ms), 75th_lat(ms), 90th_lat(ms), 95th_lat(ms), 99th_lat(ms), max_lat(ms), tp (req/s) scaled");
out.println(String.format("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, tp (req/s) scaled",
TIME_LABEL,
THROUGHPUT_LABEL,
LatencyRecord.METRIC_LABELS.get("AVERAGE"),
LatencyRecord.METRIC_LABELS.get("MINIMUM"),
LatencyRecord.METRIC_LABELS.get("25TH_PERCENTILE"),
LatencyRecord.METRIC_LABELS.get("MEDIAN"),
LatencyRecord.METRIC_LABELS.get("75TH_PERCENTILE"),
LatencyRecord.METRIC_LABELS.get("90TH_PERCENTILE"),
LatencyRecord.METRIC_LABELS.get("95TH_PERCENTILE"),
LatencyRecord.METRIC_LABELS.get("99TH_PERCENTILE"),
LatencyRecord.METRIC_LABELS.get("MAXIMUM")
));
int i = 0;
for (DistributionStatistics s : new TimeBucketIterable(latencySamples, windowSizeSeconds, txType)) {
final double MILLISECONDS_FACTOR = 1e3;
out.printf("%d,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f\n", i * windowSizeSeconds, (double) s.getCount() / windowSizeSeconds, s.getAverage() / MILLISECONDS_FACTOR,
s.getMinimum() / MILLISECONDS_FACTOR, s.get25thPercentile() / MILLISECONDS_FACTOR, s.getMedian() / MILLISECONDS_FACTOR, s.get75thPercentile() / MILLISECONDS_FACTOR,
s.get90thPercentile() / MILLISECONDS_FACTOR, s.get95thPercentile() / MILLISECONDS_FACTOR, s.get99thPercentile() / MILLISECONDS_FACTOR, s.getMaximum() / MILLISECONDS_FACTOR,
Expand All @@ -108,18 +123,18 @@ public void writeCSV2(PrintStream out) {

public void writeCSV2(int windowSizeSeconds, PrintStream out, TransactionType txType) {
String header[] = {
"Time (seconds)",
TIME_LABEL,
"Requests",
"Throughput (requests/second)",
"Minimum Latency (microseconds)",
"25th Percentile Latency (microseconds)",
"Median Latency (microseconds)",
"Average Latency (microseconds)",
"75th Percentile Latency (microseconds)",
"90th Percentile Latency (microseconds)",
"95th Percentile Latency (microseconds)",
"99th Percentile Latency (microseconds)",
"Maximum Latency (microseconds)"
THROUGHPUT_LABEL,
LatencyRecord.METRIC_LABELS.get("AVERAGE"),
LatencyRecord.METRIC_LABELS.get("MINIMUM"),
LatencyRecord.METRIC_LABELS.get("25TH_PERCENTILE"),
LatencyRecord.METRIC_LABELS.get("MEDIAN"),
LatencyRecord.METRIC_LABELS.get("75TH_PERCENTILE"),
LatencyRecord.METRIC_LABELS.get("90TH_PERCENTILE"),
LatencyRecord.METRIC_LABELS.get("95TH_PERCENTILE"),
LatencyRecord.METRIC_LABELS.get("99TH_PERCENTILE"),
LatencyRecord.METRIC_LABELS.get("MAXIMUM")
};
out.println(StringUtil.join(",", header));
int i = 0;
Expand All @@ -128,15 +143,15 @@ public void writeCSV2(int windowSizeSeconds, PrintStream out, TransactionType tx
i * windowSizeSeconds,
s.getCount(),
(double) s.getCount() / windowSizeSeconds,
(int) s.getMinimum(),
(int) s.get25thPercentile(),
(int) s.getMedian(),
(int) s.getAverage(),
(int) s.get75thPercentile(),
(int) s.get90thPercentile(),
(int) s.get95thPercentile(),
(int) s.get99thPercentile(),
(int) s.getMaximum());
(int) s.getMinimum() / MILLISECONDS_FACTOR,
(int) s.get25thPercentile() / MILLISECONDS_FACTOR,
(int) s.getMedian() / MILLISECONDS_FACTOR,
(int) s.getAverage() / MILLISECONDS_FACTOR,
(int) s.get75thPercentile() / MILLISECONDS_FACTOR,
(int) s.get90thPercentile() / MILLISECONDS_FACTOR,
(int) s.get95thPercentile() / MILLISECONDS_FACTOR,
(int) s.get99thPercentile() / MILLISECONDS_FACTOR,
(int) s.getMaximum() / MILLISECONDS_FACTOR);
i += 1;
}
}
Expand Down