1

I am making use of java visualvm for profiling purpose. I am facing two issues:

1) As statetd in the documentation

When a new local Java application is launched, a node for that application appears under the Local node. The application node disappears when the application terminates.

This things happens with me when I run my java application, it runs for seconds. The Visualvm shows this PID but when my program stops then this PID also disappears.

How can I solve this problem?

Secondly, I run the main function in which there are calls to other functions present in other classes. I want to compute time for those functions as well . How can I achieve this task?

4

1 回答 1

3
  1. 不是问题。当 java 进程终止时,您将无法再连接到它。
  2. 您可以运行相同的代码 1000 次并在 visualVM 中创建快照以分析内存、计算等的使用情况。您必须将结果除以 1000。

这会为您提供更好的结果(运行 1000 次并取平均值),因为单次运行在每次运行时可能需要不同的时间。

于 2013-06-22T13:40:29.890 回答