gpt4 book ai didi

java - 使用 JRAT Java 运行时分析工具包分析简单的 java 程序

转载 作者:行者123 更新时间:2023-11-30 04:47:55 25 4
gpt4 key购买 nike

我想对我的简单 java 程序使用 JRAT 分析器,如下所示:

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");

}


}

我运行 JRAT 命令如下:java -javaagent:shiftone-jrat.jar 案例/测试/MainController

我运行以下命令来查看输出:java -Xmx256M -jar shiftone-jrat.jar

我在输出文件中看到的内容不太好。我期待某些 View 中的方法签名和方法调用层次结构。输出如下所示:

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]

有谁知道如何获取方法调用和方法签名以及方法层次结构(如调用图)?另外,查看器中的仪器和注入(inject)选项有何作用?我是分析和 JRAT 的新手。我真的很感激任何帮助。

谢谢。

最佳答案

终于我知道为什么我看不到正确的输出了。我使用的是旧版本的 JRAT。如果您使用下面的版本,它会显示正确的输出。

http://pages.cpsc.ucalgary.ca/~jacobs/Courses/cpsc331/W07/java/profiler.html

关于java - 使用 JRAT Java 运行时分析工具包分析简单的 java 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10550131/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com