Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Generate Benchmark Graphs Easily

DZone's Guide to

Generate Benchmark Graphs Easily

· Java Zone
Free Resource

Managing a MongoDB deployment? Take a load off and live migrate to MongoDB Atlas, the official automated service, with little to no downtime.

After launching a lot of benchmarks for the file copy benchmark and always generating the graphs from the results in Excel, I realized that I was losing a lot of time. So like any Java developer, I decided to create a little tool that would do the work automatically for me. For creating benchmarks, I’m using a little micro-benchmarking framework, described here. After the results are generated, I automatically generate a bar chart of the results using JFreeChart.

Here is an example of graph generated by the tool :

Example graph

Example graph

Usage of the library

The usage is quite simple. By example, if you want to benchmark two methods :

public void method1(){
    //Code...
}

public void method2(){
    //Code...
}

Start creating a Benchs :

Benchs benchs = new Benchs("Title of the benchmark");

benchs.setFolder("folder_path");

folder_path indicates the folder were the graphs will be generated.

And let’s start the benchs :

benchs.bench("First method", new Runnable(){
    public void run() {
        method1();
    }
});

benchs.bench("Second method", new Runnable(){
    public void run() {
        method2();
    }
});

benchs.generateCharts();

The charts will be generated in the specified folder.

Sub chart

If in the first graph, there are some methods that take a lot more time than the others. A sub chart will be generated including only the best methods. The methods to be removed from the graph to create the sub graph are selected using an exclusion factor. All the benchmarks with mean exclusionFactor times higher than another benchmark mean will be excluded. You can configure the exclusion factor using the setExclusionFactor setter. The default is 50.

You can download it here : benchmark-utils.tar.gz

You can consult the GitHub website for more informations and to get the source

From http://www.baptiste-wicht.com/2010/08/generate-graphs-benchmarks-easily

MongoDB Atlas is the easiest way to run the fastest-growing database for modern applications — no installation, setup, or configuration required. Easily live migrate an existing workload or start with 512MB of storage for free.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}