Search in sources :

Example 96 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project hive by apache.

the class HMSBenchmarks method benchmarkListManyPartitions.

static DescriptiveStatistics benchmarkListManyPartitions(@NotNull MicroBenchmark bench, @NotNull BenchData data, int howMany) {
    final HMSClient client = data.getClient();
    String dbName = data.dbName;
    String tableName = data.tableName;
    BenchmarkUtils.createPartitionedTable(client, dbName, tableName);
    try {
        addManyPartitions(client, dbName, tableName, null, Collections.singletonList("d"), howMany);
        LOG.debug("Created {} partitions", howMany);
        LOG.debug("started benchmark... ");
        return bench.measure(() -> throwingSupplierWrapper(() -> client.listPartitions(dbName, tableName)));
    } catch (TException e) {
        e.printStackTrace();
        return new DescriptiveStatistics();
    } finally {
        throwingSupplierWrapper(() -> client.dropTable(dbName, tableName));
    }
}
Also used : TException(org.apache.thrift.TException) DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)

Example 97 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project hive by apache.

the class HMSBenchmarks method benchmarkListPartition.

static DescriptiveStatistics benchmarkListPartition(@NotNull MicroBenchmark bench, @NotNull BenchData data) {
    final HMSClient client = data.getClient();
    String dbName = data.dbName;
    String tableName = data.tableName;
    BenchmarkUtils.createPartitionedTable(client, dbName, tableName);
    try {
        addManyPartitions(client, dbName, tableName, null, Collections.singletonList("d"), 1);
        return bench.measure(() -> throwingSupplierWrapper(() -> client.listPartitions(dbName, tableName)));
    } catch (TException e) {
        e.printStackTrace();
        return new DescriptiveStatistics();
    } finally {
        throwingSupplierWrapper(() -> client.dropTable(dbName, tableName));
    }
}
Also used : TException(org.apache.thrift.TException) DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)

Example 98 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project hive by apache.

the class MicroBenchmark method measure.

/**
 * Run the benchmark and measure run-time statistics in nanoseconds.<p>
 * Before the run the warm-up phase is executed.
 * @param pre Optional pre-test setup
 * @param test Mandatory test
 * @param post Optional post-test cleanup
 * @return Statistics describing the results. All times are in nanoseconds.
 */
public DescriptiveStatistics measure(@Nullable Runnable pre, @NotNull Runnable test, @Nullable Runnable post) {
    // Warmup phase
    for (int i = 0; i < warmup; i++) {
        if (pre != null) {
            pre.run();
        }
        test.run();
        if (post != null) {
            post.run();
        }
    }
    // Run the benchmark
    DescriptiveStatistics stats = new DescriptiveStatistics();
    for (int i = 0; i < iterations; i++) {
        if (pre != null) {
            pre.run();
        }
        long start = System.nanoTime();
        test.run();
        long end = System.nanoTime();
        stats.addValue((double) (end - start) / scaleFactor);
        if (post != null) {
            post.run();
        }
    }
    return stats;
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)

Example 99 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project jmeter by apache.

the class TestStatCalculator method testMedianBug61071.

@Test
@Disabled
public // Disabled due to in progress Bug 61071
void testMedianBug61071() {
    long[] values = new long[] { 10L, 20L, 30L, 40L, 50L, 60L, 80L, 90L };
    DescriptiveStatistics statistics = new DescriptiveStatistics();
    for (long l : values) {
        calc.addValue(l);
        statistics.addValue(l);
    }
    assertEquals((int) statistics.getPercentile(50), calc.getMedian().intValue());
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 100 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project jmeter by apache.

the class DescriptiveStatisticsFactory method createDescriptiveStatistics.

public static DescriptiveStatistics createDescriptiveStatistics(int windowSize) {
    DescriptiveStatistics statistics = new DescriptiveStatistics(windowSize);
    statistics.setPercentileImpl(new Percentile().withEstimationType(ESTIMATION_TYPE));
    return statistics;
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) Percentile(org.apache.commons.math3.stat.descriptive.rank.Percentile)

Aggregations

DescriptiveStatistics (org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)181 ArrayList (java.util.ArrayList)22 List (java.util.List)17 Test (org.testng.annotations.Test)15 Test (org.junit.Test)13 Test (org.junit.jupiter.api.Test)12 File (java.io.File)11 Plot (ij.gui.Plot)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 Rectangle (java.awt.Rectangle)8 TException (org.apache.thrift.TException)7 Result (de.dagere.kopeme.generated.Result)6 LinkedList (java.util.LinkedList)6 AbstractMagmaTest (org.obiba.magma.test.AbstractMagmaTest)6 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)6 PrecisionResultProcedure (uk.ac.sussex.gdsc.smlm.results.procedures.PrecisionResultProcedure)6 ImagePlus (ij.ImagePlus)5 PlotWindow (ij.gui.PlotWindow)5 ImageProcessor (ij.process.ImageProcessor)5 Map (java.util.Map)5