I’m a swiss Master student in Computer Science. I’m very interested in C++, open source projects, Linux, Intel Assembly and Agile. I'm currently working on Eddi, a new programming language that I created to improve my skills in C++. I've also worked a lot on Java technologies (Sprint, Osgi, Play!, ...), but I'm not currently working with Java anymore. Baptiste is a DZone MVB and is not an employee of DZone and has posted 51 posts at DZone. You can read more from them at their website. View Full User Profile

Generate Benchmark Graphs Easily

08.12.2010
| 4942 views |
  • submit to reddit

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

Published at DZone with permission of Baptiste Wicht, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Thomas Eichberger replied on Thu, 2010/08/12 - 8:00am

Nice idea.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.