I want to use JRAT profiler for my simple java program which is as below:
public class MainController {
public static int a=4;
public static void main(String[] args) {
for(int i=0;i<30;i++)
{
methodA();
//System.out.println("Hello");
}
}
static void methodA()
{
System.out.println("This is Method A");
methodB();
}
static void methodB()
{
System.out.println("This is Method B");
methodC();
}
static void methodC()
{
System.out.println("This is Method C");
}
}
I run JRAT command as below:
java -javaagent:shiftone-jrat.jar cased/test/MainController
I run following command to see the output:
java -Xmx256M -jar shiftone-jrat.jar
What I see in outputfile is not so good. I was expecting method signature and method call heirarchy in some of the view. Output looks like below:
viewer="org.shiftone.jrat.ui.viewer.SimpleTextOutputViewBuilder"
JRat:INFO (May/11 12:32:57,613) (main) RuntimeContextImpl - logfile created
JRat:INFO (May/11 12:32:57,613) (main) RuntimeContextImpl - Running JRat version 1-alpha2 - built on July 31 2006
JRat:INFO (May/11 12:32:57,614) (main) Settings - string 'jrat.factory' = 'org.shiftone.jrat.provider.silent.SilentMethodHandler'
JRat:INFO (May/11 12:32:57,614) (main) RootFactory - JRat creating root handler factory...
JRat:INFO (May/11 12:32:57,618) (JRat-Shutdown) ShutdownRegistry - shutting down...[Transformer[AsmInjectorStrategy(uses http://asm.objectweb.org)], FileOutputRegistry[PrintWriter[001_JRat-LOG.jrat]]]
JRat:INFO (May/11 12:32:57,618) (JRat-Shutdown) ShutdownRegistry - shutting down FileOutputRegistry[PrintWriter[001_JRat-LOG.jrat]]...
JRat:INFO (May/11 12:32:57,618) (JRat-Shutdown) FileOutputRegistry - closeFileOutputs [PrintWriter[001_JRat-LOG.jrat]]
JRat:INFO (May/11 12:32:57,618) (JRat-Shutdown) FileOutputRegistry - closing : PrintWriter[001_JRat-LOG.jrat]
JRat:INFO (May/11 12:32:57,619) (JRat-Shutdown) FileOutputPrintWriter - closing
JRat:INFO (May/11 12:32:57,619) (JRat-Shutdown) FileOutputRegistry - remove PrintWriter[001_JRat-LOG.jrat]
Does anyone know how to get method call and method signature and also method hierarchy(like call graph) ? Also what is instrumentation and injection options do in the viewer ?
I am new to profiling and JRAT. I would really appreciate any help.
Thanks.
Finally I found out why I could not see the proper output. I used the older version of JRAT. If u use version below, it shows the proper output.
http://pages.cpsc.ucalgary.ca/~jacobs/Courses/cpsc331/W07/java/profiler.html