add bar charts
This commit is contained in:
@@ -10,7 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
public class AxisSettings {
|
||||
|
||||
public enum Type {
|
||||
Number, Time, Duration, Percent, HistogramBin, HistogramCount
|
||||
Number, Time, Duration, Percent, HistogramBin, HistogramCount, Group
|
||||
}
|
||||
|
||||
private String format = "";
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
package org.lucares.recommind.logs;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggregatedDataCollection;
|
||||
import org.lucares.pdb.plot.api.AggregatorCollection;
|
||||
|
||||
class CsvSummary {
|
||||
private final int values;
|
||||
private final long maxValue;
|
||||
private final AggregatedDataCollection aggregatedData;
|
||||
private final AggregatorCollection aggregators;
|
||||
private final double statsAverage;
|
||||
private final int plottedValues;
|
||||
|
||||
public CsvSummary(final int values, final int plottedValues, final long maxValue, final double statsAverage,
|
||||
final AggregatedDataCollection aggregatedData) {
|
||||
final AggregatorCollection aggregators) {
|
||||
super();
|
||||
this.values = values;
|
||||
this.plottedValues = plottedValues;
|
||||
this.maxValue = maxValue;
|
||||
this.statsAverage = statsAverage;
|
||||
this.aggregatedData = aggregatedData;
|
||||
this.aggregators = aggregators;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ class CsvSummary {
|
||||
return statsAverage;
|
||||
}
|
||||
|
||||
public AggregatedDataCollection getAggregatedData() {
|
||||
return aggregatedData;
|
||||
public AggregatorCollection getAggregators() {
|
||||
return aggregators;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggregatedDataCollection;
|
||||
import org.lucares.pdb.plot.api.AggregatorCollection;
|
||||
import org.lucares.pdb.plot.api.Limit;
|
||||
|
||||
public interface DataSeries {
|
||||
@@ -41,7 +41,7 @@ public interface DataSeries {
|
||||
|
||||
public LineStyle getStyle();
|
||||
|
||||
public AggregatedDataCollection getAggregatedData();
|
||||
public AggregatorCollection getAggregators();
|
||||
|
||||
public static Map<String, Integer> toMap(final List<DataSeries> dataSeries) {
|
||||
final Map<String, Integer> result = new LinkedHashMap<>();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.lucares.recommind.logs;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggregatedDataCollection;
|
||||
import org.lucares.pdb.plot.api.AggregatorCollection;
|
||||
|
||||
public class FileBackedDataSeries implements DataSeries {
|
||||
|
||||
@@ -64,7 +64,7 @@ public class FileBackedDataSeries implements DataSeries {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AggregatedDataCollection getAggregatedData() {
|
||||
return csvSummary.getAggregatedData();
|
||||
public AggregatorCollection getAggregators() {
|
||||
return csvSummary.getAggregators();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ public interface GnuplotColorPalettes {
|
||||
);
|
||||
|
||||
List<GnuplotColor> GNUPLOT_REORDERED = Arrays.asList(//
|
||||
GnuplotColor.byHex("0072b2"), // blue
|
||||
GnuplotColor.byHex("e69f00"), // orange
|
||||
GnuplotColor.byHex("9400D3"), // purple
|
||||
GnuplotColor.byHex("0072b2"), // blue 00A2FF, 0091E6, 0072B2, 005180, 002840
|
||||
GnuplotColor.byHex("e69f00"), // orange FFAE00, E69F00, BF8300, 805700, 402C00
|
||||
GnuplotColor.byHex("9400D3"), // purple B300FF, A100E6, 9400D3, 590080, 2D0040
|
||||
GnuplotColor.byHex("009e73"), // green
|
||||
GnuplotColor.byHex("f0e442"), // yellow
|
||||
GnuplotColor.byHex("e51e10"), // red
|
||||
|
||||
@@ -64,6 +64,9 @@ public class GnuplotFileGenerator implements Appender {
|
||||
}
|
||||
}
|
||||
|
||||
// appendfln(result, "set xrange [-1:1]");
|
||||
appendfln(result, "set boxwidth 0.5");
|
||||
|
||||
appendf(result, "plot ");
|
||||
|
||||
settings.getAggregates().addPlots(result, dataSeries);
|
||||
|
||||
@@ -3,11 +3,13 @@ package org.lucares.recommind.logs;
|
||||
public enum GnuplotLineType {
|
||||
LINE("line"),
|
||||
|
||||
Bar("boxes"),
|
||||
|
||||
Points("points");
|
||||
|
||||
private String gnuplotLineType;
|
||||
|
||||
GnuplotLineType(String gnuplotLineType) {
|
||||
GnuplotLineType(final String gnuplotLineType) {
|
||||
this.gnuplotLineType = gnuplotLineType;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.lucares.pdb.plot.api.Limit;
|
||||
import org.lucares.pdb.plot.api.PlotSettings;
|
||||
import org.lucares.pdb.plot.api.TimeRangeUnitInternal;
|
||||
import org.lucares.performance.db.PerformanceDb;
|
||||
import org.lucares.utils.file.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -35,8 +34,6 @@ public class Plotter {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Plotter.class);
|
||||
private static final Logger METRICS_LOGGER = LoggerFactory.getLogger("org.lucares.metrics.plotter.scatter");
|
||||
|
||||
static final String DEFAULT_GROUP = "<none>";
|
||||
|
||||
private final PerformanceDb db;
|
||||
private final Path tmpBaseDir;
|
||||
private final Path outputDir;
|
||||
@@ -95,6 +92,7 @@ public class Plotter {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
});
|
||||
|
||||
METRICS_LOGGER.debug("csv generation took: " + (System.nanoTime() - start) / 1_000_000.0 + "ms");
|
||||
|
||||
final Limit limitBy = plotSettings.getLimitBy();
|
||||
@@ -145,7 +143,7 @@ public class Plotter {
|
||||
} catch (final IOException e) {
|
||||
throw new InternalPlottingException("Plotting failed: " + e.getMessage(), e);
|
||||
} finally {
|
||||
FileUtils.delete(tmpDir);
|
||||
// XXX TODO revert: FileUtils.delete(tmpDir);
|
||||
LOGGER.trace("done plot");
|
||||
}
|
||||
}
|
||||
@@ -166,6 +164,7 @@ public class Plotter {
|
||||
|
||||
final long start = System.nanoTime();
|
||||
final Stream<LongList> timeValueStream = groupResult.asStream();
|
||||
final Tags groupedBy = groupResult.getGroupedBy();
|
||||
final long fromEpochMilli = dateFrom.toInstant().toEpochMilli();
|
||||
final long toEpochMilli = dateTo.toInstant().toEpochMilli();
|
||||
final boolean useMillis = (toEpochMilli - fromEpochMilli) < TimeUnit.MINUTES.toMillis(5);
|
||||
@@ -206,21 +205,21 @@ public class Plotter {
|
||||
statsCurrentAverage = statsCurrentAverage + (value - statsCurrentAverage) / count;
|
||||
|
||||
// check if value is in the selected y-range
|
||||
boolean valueIsInYRange = value < minValue || value > maxValue;
|
||||
final boolean valueIsInYRange = value < minValue || value > maxValue;
|
||||
if (valueIsInYRange) {
|
||||
ignoredValues++;
|
||||
} else {
|
||||
plottedValues++;
|
||||
}
|
||||
|
||||
aggregator.addValue(valueIsInYRange, epochMilli, value);
|
||||
aggregator.addValue(groupedBy, valueIsInYRange, epochMilli, value);
|
||||
}
|
||||
}
|
||||
|
||||
METRICS_LOGGER.debug("wrote {} values to csv in: {}ms (ignored {} values) use millis: {}, grouping={}",
|
||||
plottedValues, (System.nanoTime() - start) / 1_000_000.0, ignoredValues, Boolean.toString(useMillis),
|
||||
groupResult.getGroupedBy().asString());
|
||||
return new CsvSummary(count, plottedValues, statsMaxValue, statsCurrentAverage, aggregator.getAggregatedData());
|
||||
return new CsvSummary(count, plottedValues, statsMaxValue, statsCurrentAverage, aggregator);
|
||||
|
||||
}
|
||||
|
||||
@@ -231,22 +230,10 @@ public class Plotter {
|
||||
|
||||
static String title(final Tags tags, final CsvSummary csvSummary) {
|
||||
|
||||
final StringBuilder result = new StringBuilder();
|
||||
final StringBuilder result = new StringBuilder(tags.asValueString());
|
||||
|
||||
final int values = csvSummary.getValues();
|
||||
final int plottedValues = csvSummary.getPlottedValues();
|
||||
|
||||
if (tags.isEmpty()) {
|
||||
result.append(DEFAULT_GROUP);
|
||||
} else {
|
||||
tags.forEach((k, v) -> {
|
||||
if (result.length() > 0) {
|
||||
result.append(" / ");
|
||||
}
|
||||
result.append(v);
|
||||
});
|
||||
}
|
||||
|
||||
result.append(" (");
|
||||
if (plottedValues != values) {
|
||||
result.append(String.format("%,d / %,d", plottedValues, values));
|
||||
|
||||
Reference in New Issue
Block a user