A JVMTI agent to be used with microbenchmarks. Basic features:

Example usage

private static final int LOOPS = 10;
private static final String[] EVENTS = {
    /* The most precise clock available. */
    "SYS:wallclock-time",
    /* Number of JIT compilation events. */
    "JVM:compilations",
    /* L1 cache misses (only Linux with PAPI). */
    "PAPI_L1_DCM"
};

public static void myBenchmark() {
    /* We would have LOOPS measurements and we
       want to record these EVENTS. */
    Benchmark.init(LOOPS, EVENTS);

    for (int i = 0; i < LOOPS; i++) {
        /* Start the measurement. */
        Benchmark.start();

        /* Here goes your code that ought to be measured. */

        /* Stop the measurement. */
        Benchmark.stop();
    }

    /* Get the results (available as Iterable<long[]>). */
    BenchmarkResults results = Benchmark.getResults();

    /* Either print them in CSV (to be later processed)... */
    BenchmarkResultsPrinter.toCsv(results, System.out);

    /* ... or as a space-padded table. */
    BenchmarkResultsPrinter.table(results, System.out);
}

To run your program with our agent, add the ubench-agent.jar to your classpath and start JVM with the C-agent: -agentpath:libubench-agent.so (GNU/Linux) or -agentpath:ubench-agent.dll (Windows).

A more generic interface Measurement is available if you wish to bind the measurement to a specific thread or if you need to measure more things at once (though internal limitations of Linux perf subsystem may apply).

More details are available in the source repository.

Repositories

Contact