use of org.apache.commons.math.stat.descriptive.DescriptiveStatistics in project pinot by linkedin.
the class PinotZKChanger method printSegmentAssignment.
protected void printSegmentAssignment(Map<String, Map<String, String>> mapping) throws Exception {
StringWriter sw = new StringWriter();
objectMapper.writerWithDefaultPrettyPrinter().writeValue(sw, mapping);
LOGGER.info(sw.toString());
Map<String, List<String>> serverToSegmentMapping = new TreeMap<>();
for (String segment : mapping.keySet()) {
Map<String, String> serverToStateMap = mapping.get(segment);
for (String server : serverToStateMap.keySet()) {
if (!serverToSegmentMapping.containsKey(server)) {
serverToSegmentMapping.put(server, new ArrayList<String>());
}
serverToSegmentMapping.get(server).add(segment);
}
}
DescriptiveStatistics stats = new DescriptiveStatistics();
for (String server : serverToSegmentMapping.keySet()) {
List<String> list = serverToSegmentMapping.get(server);
LOGGER.info("server " + server + " has " + list.size() + " segments");
stats.addValue(list.size());
}
LOGGER.info("Segment Distrbution stat");
LOGGER.info(stats.toString());
}
use of org.apache.commons.math.stat.descriptive.DescriptiveStatistics in project pinot by linkedin.
the class StatsGenerator method generateReport.
public static void generateReport(String dataFileName) throws IOException {
List<DescriptiveStatistics> statisticsList = new ArrayList<>();
String dataString;
BufferedReader dataReader = new BufferedReader(new FileReader(dataFileName));
// First line is treated as header
String[] columns = dataReader.readLine().split("\\s+");
int numColumns = columns.length;
for (int i = 0; i < numColumns; ++i) {
statisticsList.add(new DescriptiveStatistics());
}
while ((dataString = dataReader.readLine()) != null) {
String[] dataArray = dataString.trim().split(" ");
if (dataArray.length != numColumns) {
throw new RuntimeException("Row has missing columns: " + Arrays.toString(dataArray) + " Expected: " + numColumns + " columns.");
}
for (int i = 0; i < dataArray.length; ++i) {
double data = Double.valueOf(dataArray[i]);
statisticsList.get(i).addValue(data);
}
}
for (int i = 0; i < numColumns; i++) {
LOGGER.info("Stats: {}: {}", columns[i], statisticsList.get(i).toString().replace("\n", "\t"));
}
}
use of org.apache.commons.math.stat.descriptive.DescriptiveStatistics in project pinot by linkedin.
the class HeatMapViewResponse method updateStats.
public void updateStats() {
for (Map.Entry<String, GenericResponse> entry : data.entrySet()) {
GenericResponse genericResponse = entry.getValue();
Map<String, Integer> columnsToIndexMapping = genericResponse.getSchema().getColumnsToIndexMapping();
int i = columnsToIndexMapping.get("baselineValue");
int j = columnsToIndexMapping.get("currentValue");
for (String[] rowData : genericResponse.getResponseData()) {
Double baselineValue = Double.valueOf(rowData[i]);
Double currentValue = Double.valueOf(rowData[j]);
DescriptiveStatistics baselineStats = new DescriptiveStatistics();
DescriptiveStatistics currentStats = new DescriptiveStatistics();
// Add stats
// Update columns
// Update column to index mapping
}
}
}
use of org.apache.commons.math.stat.descriptive.DescriptiveStatistics in project jackrabbit-oak by apache.
the class AbstractTest method runTest.
private void runTest(RepositoryFixture fixture, Repository repository, List<Integer> concurrencyLevels) throws Exception {
setUp(repository, CREDENTIALS);
try {
// Run a few iterations to warm up the system
long warmupEnd = System.currentTimeMillis() + WARMUP;
boolean stop = false;
while (System.currentTimeMillis() < warmupEnd && !stop) {
if (!stop) {
// we want to execute this at lease once. after that we consider the
// `haltRequested` flag.
stop = haltRequested;
}
execute();
}
if (concurrencyLevels == null || concurrencyLevels.isEmpty()) {
concurrencyLevels = Arrays.asList(1);
}
for (Integer concurrency : concurrencyLevels) {
// Run the test
DescriptiveStatistics statistics = runTest(concurrency);
Object[] defaultStats = new Object[] { fixture.toString(), concurrency, statistics.getMin(), statistics.getPercentile(10.0), statistics.getPercentile(50.0), statistics.getPercentile(90.0), statistics.getMax(), statistics.getN() };
Object[] statsArg = ArrayUtils.addAll(defaultStats, statsValues());
String comment = comment();
if (comment != null) {
statsArg = ArrayUtils.add(statsArg, comment);
}
if (statistics.getN() > 0) {
System.out.format("%-28.28s %6d %6.0f %6.0f %6.0f %6.0f %6.0f %6d" + statsFormatsJoined(false) + "%n", statsArg);
if (out != null) {
out.format("%-28.28s, %6d, %6.0f, %6.0f, %6.0f, %6.0f, %6.0f, %6d" + statsFormatsJoined(false) + "%n", statsArg);
}
}
}
} finally {
tearDown();
}
}
use of org.apache.commons.math.stat.descriptive.DescriptiveStatistics in project sling by apache.
the class ReportLogger method writeResults.
/**
* Write all records to file in TXT format
*
* @throws Exception
*/
public void writeResults() throws Exception {
PerformanceRecord referenceRecord = records.get(referenceMethod);
for (String methodName : records.keySet()) {
DescriptiveStatistics statistics = records.get(methodName).getStatistics();
double min = statistics.getMin();
double percentile10 = statistics.getPercentile(10);
double percentile50 = statistics.getPercentile(50);
double percentile90 = statistics.getPercentile(90);
double max = statistics.getMax();
boolean showDecimals = false;
if (referenceRecord != null && !referenceMethod.equals(methodName)) {
DescriptiveStatistics referenceStatistics = referenceRecord.getStatistics();
double ref = referenceStatistics.getMin();
min = ref == 0 ? Double.POSITIVE_INFINITY : min / ref;
ref = referenceStatistics.getPercentile(10);
percentile10 = ref == 0 ? Double.POSITIVE_INFINITY : percentile10 / ref;
ref = referenceStatistics.getPercentile(50);
percentile50 = ref == 0 ? Double.POSITIVE_INFINITY : percentile50 / ref;
ref = referenceStatistics.getPercentile(90);
percentile90 = ref == 0 ? Double.POSITIVE_INFINITY : percentile90 / ref;
ref = referenceStatistics.getMax();
max = ref == 0 ? Double.POSITIVE_INFINITY : max / referenceStatistics.getMax();
showDecimals = true;
}
ReportLogger.writeReportTxt(testSuiteName, testCaseName, Class.forName(className).getSimpleName(), methodName, min, percentile10, percentile50, percentile90, max, PerformanceRunner.ReportLevel.MethodLevel, showDecimals);
}
}
Aggregations