Search in sources :

Example 1 with Results

use of org.jgroups.tests.perf.PerfUtil.Results in project JGroups by belaban.

the class UPerf method startBenchmark.

/**
 * Kicks off the benchmark on all cluster nodes
 */
void startBenchmark() {
    RspList<Results> responses = null;
    try {
        RequestOptions options = new RequestOptions(ResponseMode.GET_ALL, 0).flags(Message.Flag.OOB, Message.Flag.DONT_BUNDLE, Message.Flag.NO_FC);
        responses = disp.callRemoteMethods(null, new MethodCall(START), options);
    } catch (Throwable t) {
        System.err.println("starting the benchmark failed: " + t);
        return;
    }
    long total_reqs = 0;
    long total_time = 0;
    AverageMinMax avg_gets = null, avg_puts = null;
    System.out.println("\n======================= Results: ===========================");
    for (Map.Entry<Address, Rsp<Results>> entry : responses.entrySet()) {
        Address mbr = entry.getKey();
        Rsp<Results> rsp = entry.getValue();
        Results result = rsp.getValue();
        if (result != null) {
            total_reqs += result.num_gets + result.num_puts;
            total_time += result.total_time;
            if (avg_gets == null)
                avg_gets = result.avg_gets;
            else
                avg_gets.merge(result.avg_gets);
            if (avg_puts == null)
                avg_puts = result.avg_puts;
            else
                avg_puts.merge(result.avg_puts);
        }
        System.out.println(mbr + ": " + result);
    }
    double total_reqs_sec = total_reqs / (total_time / 1000.0);
    double throughput = total_reqs_sec * BUFFER.length;
    System.out.println("\n");
    System.out.println(Util.bold(String.format("Throughput: %,.2f reqs/sec/node (%s/sec)\n" + "Roundtrip:  gets %s, puts %s\n", total_reqs_sec, Util.printBytes(throughput), print(avg_gets, print_details), print(avg_puts, print_details))));
    System.out.println("\n\n");
}
Also used : RequestOptions(org.jgroups.blocks.RequestOptions) MethodCall(org.jgroups.blocks.MethodCall) Results(org.jgroups.tests.perf.PerfUtil.Results)

Example 2 with Results

use of org.jgroups.tests.perf.PerfUtil.Results in project JGroups by belaban.

the class UPerf method startTest.

// =================================== callbacks ======================================
public Results startTest() throws Throwable {
    BUFFER = new byte[msg_size];
    System.out.printf("running for %d seconds\n", time);
    final CountDownLatch latch = new CountDownLatch(1);
    num_reads.reset();
    num_writes.reset();
    Invoker[] invokers = new Invoker[num_threads];
    Thread[] threads = new Thread[num_threads];
    for (int i = 0; i < threads.length; i++) {
        invokers[i] = new Invoker(members, latch);
        threads[i] = thread_factory.newThread(invokers[i]);
        threads[i].setName("invoker-" + (i + 1));
        // waits on latch
        threads[i].start();
    }
    long start = System.currentTimeMillis();
    latch.countDown();
    long interval = (long) ((time * 1000.0) / 10.0);
    for (int i = 1; i <= 10; i++) {
        Util.sleep(interval);
        System.out.printf("%d: %s\n", i, printAverage(start));
    }
    for (Invoker invoker : invokers) invoker.stop();
    for (Thread t : threads) t.join();
    long total_time = System.currentTimeMillis() - start;
    System.out.println();
    AverageMinMax avg_gets = null, avg_puts = null;
    for (int i = 0; i < invokers.length; i++) {
        Invoker invoker = invokers[i];
        if (print_invokers)
            System.out.printf("invoker %s: gets %s puts %s\n", threads[i].getId(), print(invoker.avgGets(), print_details), print(invoker.avgPuts(), print_details));
        if (avg_gets == null)
            avg_gets = invoker.avgGets();
        else
            avg_gets.merge(invoker.avgGets());
        if (avg_puts == null)
            avg_puts = invoker.avgPuts();
        else
            avg_puts.merge(invoker.avgPuts());
    }
    if (print_invokers)
        System.out.printf("\navg over all invokers: gets %s puts %s\n", print(avg_gets, print_details), print(avg_puts, print_details));
    System.out.printf("\ndone (in %s ms)\n", total_time);
    return new Results((int) num_reads.sum(), (int) num_writes.sum(), total_time, avg_gets, avg_puts);
}
Also used : Results(org.jgroups.tests.perf.PerfUtil.Results) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Results (org.jgroups.tests.perf.PerfUtil.Results)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 MethodCall (org.jgroups.blocks.MethodCall)1 RequestOptions (org.jgroups.blocks.RequestOptions)1