Introduction
The Basher YourKit Integration is a library which, when plugged in together with the Basher runtime, allows for automatic control of YourKit CPU profiling as part of a Basher run.
By combining Basher's ability to exercise an application in a threaded fashion with YourKit's profiling agent, it is now possible to create CPU profiling snapshots as part of your Maven builds. The build can run over night and the profiling snapshot is available in the morning, ready for analysis.
YourKit profiling is started at the beginning of the RUN phase, whenever collection is started. A snapshot is captured at the end, whenever collection is stopped.
Controlling Profiling
To enable automatic profiling control in Basher, the following needs to be installed and/or configured:
- Download and install YourKit (goto)
- Make sure your library path (or path if running on Windows) points to the location of your YourKit installation
bash$ export LD_LIBRARY_PATH=$YOURKIT_HOME/bin/<your-platform>
- Edit your settings.xml (most commonly located in $HOME/.m2/settings.xml) and add a property called yourkit.installation.directory. This should point to the installation directory of YourKit.
... <profiles> ... <profile> <id>basher</id> <properties> <yourkit.installation.directory>Path to YourKit home</yourkit.installation.directory> </properties> </profile> </profiles> ...
- Add a dependency to the Basher YourKit jar to your project
... <dependencies> ... <dependency> <groupId>net.sourceforge.basher</groupId> <artifactId>basher-yourkit</artifactId> <version>0.1</version> </dependency> ... </dependencies> ...
- Configure YourKit profiling for the Maven Basher plugin configuration
... <plugins> ... <plugin> <groupId>net.sourceforge.basher</groupId> <artifactId>maven-basher-plugin</artifactId> ... <configuration> ... <profiler>yourkit</profiler> ... <basherContexts> ... <basherContext implementation="net.sourceforge.basher.BasherContext"> <name>yourkit</name> ... <profilerContext implementation="net.sourceforge.basher.YourKitProfilerContext"/> ... </basherContext> </basherContexts> </configuration> </plugin> </plugins> ...
- Run the Maven Basher plugin. If successful, you should see the YourKit controller initializing as shown in the log snippet below.
[INFO] Initiating forking run 2010-05-06 10:08:58,219 INFO YourKitController [initializeService] Initializing YourKit Controller 2010-05-06 10:08:58,225 INFO YourKitController [initializeService] Hostname: localhost 2010-05-06 10:08:58,226 INFO YourKitController [initializeService] Port: 10020 2010-05-06 10:08:58,231 INFO YourKitController [connect] Connecting to profiling agent 2010-05-06 10:08:58,297 INFO YourKitController [connect] Successfully connected to profiling agent