Search in sources :

Example 1 with DescriptiveStatistics

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());
}
Also used : DescriptiveStatistics(org.apache.commons.math.stat.descriptive.DescriptiveStatistics) StringWriter(java.io.StringWriter) ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap)

Example 2 with DescriptiveStatistics

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"));
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math.stat.descriptive.DescriptiveStatistics) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader)

Example 3 with DescriptiveStatistics

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
        }
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math.stat.descriptive.DescriptiveStatistics) GenericResponse(com.linkedin.thirdeye.dashboard.views.GenericResponse) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with DescriptiveStatistics

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();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SynchronizedDescriptiveStatistics(org.apache.commons.math.stat.descriptive.SynchronizedDescriptiveStatistics) DescriptiveStatistics(org.apache.commons.math.stat.descriptive.DescriptiveStatistics)

Example 5 with DescriptiveStatistics

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);
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math.stat.descriptive.DescriptiveStatistics)

Aggregations

DescriptiveStatistics (org.apache.commons.math.stat.descriptive.DescriptiveStatistics)14 ArrayList (java.util.ArrayList)5 File (java.io.File)4 TimeValue (alma.acs.algorithms.DataBinner.TimeValue)3 DataBinner (alma.acs.algorithms.DataBinner)2 BinnedTimeValues (alma.acs.algorithms.DataBinner.BinnedTimeValues)2 PrintStream (java.io.PrintStream)2 List (java.util.List)2 ComponentRequest (alma.acs.manager.logparser.ManagerStdoutParser.ComponentRequest)1 RateLimiter (com.google.common.util.concurrent.RateLimiter)1 GenericResponse (com.linkedin.thirdeye.dashboard.views.GenericResponse)1 ByteBuf (io.netty.buffer.ByteBuf)1 BufferedReader (java.io.BufferedReader)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 StringWriter (java.io.StringWriter)1 Method (java.lang.reflect.Method)1 InetAddress (java.net.InetAddress)1