Search in sources :

Example 1 with SynchronizedDescriptiveStatistics

use of org.apache.commons.math.stat.descriptive.SynchronizedDescriptiveStatistics in project jackrabbit-oak by apache.

the class ScalabilityNodeSuite method createLoad.

/**
 * Creates the load for the search.
 *
 * @param context the context
 * @throws RepositoryException the repository exception
 */
protected void createLoad(ExecutionContext context) throws RepositoryException {
    // Creates assets for this run
    SynchronizedDescriptiveStatistics writeStats = new SynchronizedDescriptiveStatistics();
    List<Thread> loadThreads = newArrayList();
    for (int idx = 0; idx < LOADERS; idx++) {
        /* Each loader will write to a directory of the form load-idx */
        Thread t = new Thread(getWriter(context, writeStats, idx), "LoadThread-" + idx);
        loadThreads.add(t);
        t.start();
    }
    // wait for the load threads to finish
    for (Thread t : loadThreads) {
        try {
            t.join();
        } catch (InterruptedException e) {
            LOG.error("Exception waiting for join ", e);
        }
    }
    LOG.info("Write stats");
    LOG.info(String.format("# min     10%%     50%%     90%%     max       N%n"));
    LOG.info(String.format("%6.0f  %6.0f  %6.0f  %6.0f  %6.0f  %6d%n", writeStats.getMin(), writeStats.getPercentile(10.0), writeStats.getPercentile(50.0), writeStats.getPercentile(90.0), writeStats.getMax(), writeStats.getN()));
}
Also used : SynchronizedDescriptiveStatistics(org.apache.commons.math.stat.descriptive.SynchronizedDescriptiveStatistics)

Example 2 with SynchronizedDescriptiveStatistics

use of org.apache.commons.math.stat.descriptive.SynchronizedDescriptiveStatistics in project jackrabbit-oak by apache.

the class AbstractTest method runTest.

private DescriptiveStatistics runTest(int concurrencyLevel) throws Exception {
    final SynchronizedDescriptiveStatistics statistics = new SynchronizedDescriptiveStatistics();
    if (concurrencyLevel == 1) {
        // Run test iterations, and capture the execution times
        long runtimeEnd = System.currentTimeMillis() + RUNTIME;
        boolean stop = false;
        while (System.currentTimeMillis() < runtimeEnd && !stop) {
            if (!stop) {
                // we want to execute this at lease once. after that we consider the
                // `haltRequested` flag.
                stop = haltRequested;
            }
            statistics.addValue(execute());
        }
    } else {
        List<Executor> threads = new LinkedList<Executor>();
        for (int n = 0; n < concurrencyLevel; n++) {
            threads.add(new Executor("Background job " + n, statistics));
        }
        // start threads
        for (Thread t : threads) {
            t.start();
        }
        // System.out.printf("Started %d threads%n", threads.size());
        // Run test iterations, and capture the execution times
        long runtimeEnd = System.currentTimeMillis() + RUNTIME;
        while (System.currentTimeMillis() < runtimeEnd) {
            Thread.sleep(runtimeEnd - System.currentTimeMillis());
        }
        // stop threads
        for (Executor e : threads) {
            e.running = false;
        }
        // wait for threads
        for (Executor e : threads) {
            e.join();
        }
    }
    return statistics;
}
Also used : SynchronizedDescriptiveStatistics(org.apache.commons.math.stat.descriptive.SynchronizedDescriptiveStatistics) LinkedList(java.util.LinkedList)

Example 3 with SynchronizedDescriptiveStatistics

use of org.apache.commons.math.stat.descriptive.SynchronizedDescriptiveStatistics in project jackrabbit-oak by apache.

the class ScalabilityAbstractSuite method runIteration.

/**
 * Runs the iteration of the benchmarks added.
 *
 * @param context the execution context
 * @throws Exception
 */
private void runIteration(ExecutionContext context) throws Exception {
    Preconditions.checkArgument(benchmarks != null && !benchmarks.isEmpty(), "No Benchmarks configured");
    for (String key : benchmarks.keySet()) {
        ScalabilityBenchmark benchmark = benchmarks.get(key);
        if (result.getBenchmarkStatistics(benchmark) == null) {
            result.addBenchmarkStatistics(benchmark, new SynchronizedDescriptiveStatistics());
        }
        Stopwatch watch = Stopwatch.createStarted();
        executeBenchmark(benchmark, context);
        watch.stop();
        result.getBenchmarkStatistics(benchmark).addValue(watch.elapsed(TimeUnit.MILLISECONDS));
        if (LOG.isDebugEnabled()) {
            LOG.debug("Execution time for " + benchmark + "-" + watch.elapsed(TimeUnit.MILLISECONDS));
        }
    }
}
Also used : SynchronizedDescriptiveStatistics(org.apache.commons.math.stat.descriptive.SynchronizedDescriptiveStatistics) ScalabilityBenchmark(org.apache.jackrabbit.oak.scalability.benchmarks.ScalabilityBenchmark) Stopwatch(com.google.common.base.Stopwatch)

Aggregations

SynchronizedDescriptiveStatistics (org.apache.commons.math.stat.descriptive.SynchronizedDescriptiveStatistics)3 Stopwatch (com.google.common.base.Stopwatch)1 LinkedList (java.util.LinkedList)1 ScalabilityBenchmark (org.apache.jackrabbit.oak.scalability.benchmarks.ScalabilityBenchmark)1