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));
}
}
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));
}
}
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;
}
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());
}
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;
}
Aggregations