Over a million developers have joined DZone.

Generate Benchmark Graphs Easily

· Java Zone

Easily build powerful user management, authentication, and authorization into your web and mobile applications. Download this Forrester report on the new landscape of Customer Identity and Access Management, brought to you in partnership with Stormpath.

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(){

public void method2(){

Start creating a Benchs :

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


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() {

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


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

Building Identity Management, including authentication and authorization? Try Stormpath! Our REST API and robust Java SDK support can eliminate your security risk and can be implemented in minutes. Sign up, and never build auth again!


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}