如何使用YourKit Java Profiler连接到Java命令行工具? [英] How do I connect to a Java command-line tool with the YourKit Java Profiler?

查看:323
本文介绍了如何使用YourKit Java Profiler连接到Java命令行工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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?


  1. 我可以添加命令行选项
    ,它将暂停输入,
    和我不会按返回到
    继续,直到我连接到它
    从YourKit。

  2. 有一个YourKit API,我可以
    添加到我的工具,将导致它
    阻塞,直到我与
    YourKit连接?

  3. 有一个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.

请改用以下操作:

如果简档应用程序短时间运行,请在
上启用快照捕获,并退出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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆