I want to generate callgraph
from a benchmark written using the framework jmh
. I am using https://github.com/gousiosg/java-callgraph for that.
I have tried generating a static callgraph for the jar file target/benchmarks.jar
and it works. Now I want to generate the dynamic callgraph, so I used the following command:
java -jar target/benchmarks.jar -jvmArgs "-javaagent:target/javacg-0.1-SNAPSHOT-dycg-agent.jar"
But no output file callgraph.txt
is created.
Have you tried creating a dynamic call graph for a regular Java application first? Or, at least, try to invoke the host JVM with javaagent? The mere fact static call graph works does not imply the dynamic should.
If you would try dynamic, then you'll realize it does not "work" even without JMH involved. And the trick is to "include" the classes to instrument:
java -jar ~/projects/jmh/jmh-samples/target/benchmarks.jar \
-jvmArgs "-javaagent:target/javacg-0.1-SNAPSHOT-dycg-agent.jar=\"incl=org.*\"" \
Hello -f 1 -wi 5 -i 5