Java cvprof Coverage Profiler, Analysis, Reporting

Note

I recommend that you consider using Cobertura for your coverage profiling needs, as it is actively maintained, and has a better feature-set.

About

cvprof is a source-line coverage profiler for Java code, released under the terms of the LGPL. cvprof is a rewrite of JVMDICover that works under J2SDK-1.2, J2SDK-1.3 and J2SDK-1.5 (beta).

JVMDICover was written by Joel Crisp and others.

cvprof is implemented using the Java2 JVMDI interface present in Sun's Java Virtual Machines. It is a native library, loaded into the JVM at startup. The reporting portion of cvprof is implemented in the Ruby language, and the coverage profile is stored in a BerkleyDB hash file.

Example Reports

This example cvprof report shows the coverage of a number of test-case classes.

A coverage report for JUnit, after profiling JUnit's own unit test suite.

Usage

Having obtained the source and compiled the library, you should ensure that the profiler plugin will be found by the JVM. If the library isn't installed in the system library path, this can be achived by adjusting the LD_LIBRARY_PATH environmental variable. e.g., in bash,

LD_LIBRARY_PATH=/path/containing/library/
export LD_LIBRARY_PATH

Then, invoke your JVM like this,

java -Xdebug -Xnoagent -Djava.compiler=NONE -Xruncvprof some.class.Name

This will generate a coverage profile in a binary file called coverage.db, in the current directory. After the JVM has finished running, a coverage report can be generated from the coverage profile using the reporting tool,

cvprof_report.rb --sourcepath=path_to/source/files

This should produce an HTML report in a new directory called html_cvprof_report.

Status

The profiler has only be tested under Linux. The software is not quite production quality yet, though there are no known crashing issues, and those features that exist work pretty well.

Tested successfully in,

Works partially in, (see below for known issues)

Known Issues

Download

Current

2004-04-27 cvprof-0.1.2.tar.gz ~287KiB

Previous

2004-04-19 cvprof-0.1.1.tar.gz ~29KiB

2004-04-11 cvprof-0.1.0.tar.gz ~17KiB

Compiling

mkdir /tmp/cvprof
./configure --prefix=/tmp/cvprof
make
make install

This will install cvprof_report in /tmp/cvprof/bin and libcvprof.so in /tmp/cvprof/lib. If using this prefix, you will need to set LD_LIBRARY_PATH to /tmp/cvprof/lib as explained above.

Contact

<dave at badgers-in-foil.co.uk>.