如何使用YourKit Java Profiler连接到Java命令行工具? [英] How do I connect to a Java command-line tool with the YourKit Java Profiler?
问题描述
我在Java中构建了一个命令行工具,现在我想使用YourKit来配置文件。我使用类似以下命令行工具启动:
I've build a command-line tool in Java, which I would now like to profile with YourKit. I launch the command-line tool with something like:
$ java -classpath .:foo.bar.jar com.foobar.tools.TheTool arg1 arg2 arg3
它在不到2秒内运行完成。
It runs to completion in less than 2 seconds.
阅读 http:// www。 yourkit.com/docs/80/help/agent.jsp ,我尝试了以下操作:
After reading http://www.yourkit.com/docs/80/help/agent.jsp, I tried the following:
$ java -agentpath:/home/dspitzer/yjp-8.0.24/bin/linux-x86-32/libyjpagent.so -classpath .:foo.bar.jar com.foobar.tools.TheTool arg1 arg2 arg3
...我得到:
[YourKit Java Profiler 8.0.24] JVMTI version 3001016d; 14.3-b01; Sun Microsystems Inc.; mixed mode, sharing; Linux; 32-bit JVM
[YourKit Java Profiler 8.0.24] Profiler agent is listening on port 10001...
[YourKit Java Profiler 8.0.24] *** HINT ***: To get profiling results, connect to the application from the profiler UI
...
运行完成并退出。)
我猜(默认情况下,至少)YourKit设计为只连接到正在运行的应用程序。
I guess (by default, at least) YourKit is designed to only connect to running application.
我应该如何修改我的命令行工具以允许从YourKit连接?
How should I modify my command-line tool to allow connection from YourKit?
- 我可以添加命令行选项
,它将暂停输入,
和我不会按返回到
继续,直到我连接到它
从YourKit。 - 有一个YourKit API,我可以
添加到我的工具,将导致它
阻塞,直到我与
YourKit连接? - 有一个YourKit API或一个java
命令行选项,
创建一个分析快照,I
可以稍后加载和分析($ b $后) b命令行工具已完成)
with YourKit?
推荐答案
是没有办法暂停简档应用程序,直到分析器
连接;
There is no way to pause profiled application until profiler "connects"; you simply do not need to do so.
请改用以下操作:
-
从启动开启所需的性能分析模式。例如,如果
需要配置CPU使用率,请使用相应的启动选项采样或跟踪启动CPU采样或CPU跟踪
。
请参阅 http://www.yourkit.com/docs/80 /help/additional_agent_options.jsp
如果简档应用程序短时间运行,请在
上启用快照捕获,并退出onexit = snapshot 启动选项。稍后打开捕获的
快照在分析器UI中进行分析。
If profiled application is short-running, enable snapshot capture on exit with "onexit=snapshot" startup option. Later open captured snapshot in the profiler UI for analysis.
这篇关于如何使用YourKit Java Profiler连接到Java命令行工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!