From 122ae435dce1e207175d44cf0e54e41c12bcac80 Mon Sep 17 00:00:00 2001 From: Daniel Biales Date: Sun, 20 Sep 2020 03:34:39 -0400 Subject: [PATCH] #337 Trying to standardize the latency & other metric labels. I'm not sure this is the lables that we want to use but at least they are stadardized across the files. Also I'm not sure if this breaks anything with Matlab. --- .../oltpbenchmark/DistributionStatistics.java | 19 +++--- src/com/oltpbenchmark/LatencyRecord.java | 19 ++++++ src/com/oltpbenchmark/Results.java | 59 ++++++++++++------- 3 files changed, 66 insertions(+), 31 deletions(-) diff --git a/src/com/oltpbenchmark/DistributionStatistics.java b/src/com/oltpbenchmark/DistributionStatistics.java index ccca6f622..0f8490170 100644 --- a/src/com/oltpbenchmark/DistributionStatistics.java +++ b/src/com/oltpbenchmark/DistributionStatistics.java @@ -23,6 +23,7 @@ import org.apache.log4j.Logger; + public class DistributionStatistics { private static final Logger LOG = Logger.getLogger(DistributionStatistics.class); @@ -165,15 +166,15 @@ public String toString() { public Map toMap() { Map distMap = new LinkedHashMap(); - 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; } } diff --git a/src/com/oltpbenchmark/LatencyRecord.java b/src/com/oltpbenchmark/LatencyRecord.java index e296e506b..7f8871350 100644 --- a/src/com/oltpbenchmark/LatencyRecord.java +++ b/src/com/oltpbenchmark/LatencyRecord.java @@ -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 { /** Allocate space for 500k samples at a time */ static final int ALLOC_SIZE = 500000; + /** Labels for latency metrics */ + public static Map 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 diff --git a/src/com/oltpbenchmark/Results.java b/src/com/oltpbenchmark/Results.java index db083d397..5fb3aaddc 100644 --- a/src/com/oltpbenchmark/Results.java +++ b/src/com/oltpbenchmark/Results.java @@ -39,6 +39,10 @@ public final class Results { final Histogram txnRetry = new Histogram(true); final Histogram txnErrors = new Histogram(true); final Map> txnAbortMessages = new HashMap>(); + final double MILLISECONDS_FACTOR = 1e3; + /** Metrics labels */ + final String TIME_LABEL = "Time (seconds)"; + final String THROUGHPUT_LABEL = "Throughput (requests/second)"; public final List latencySamples; @@ -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, @@ -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; @@ -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; } }