corner imagecorner image FeaturesPluginsPlatformDocs & SupportCommunityPartners

nbprofiledirect

nbprofiledirect

描述

在 NetBeans IDE 中运行 nbprofiledirect 时,将启动 NetBeans Profiler。Profiler 将着手侦听特定的端口,以尝试连接运行于分析的 VM 中的代理。

该任务将立即返回,不会对其他操作造成阻塞。通常应该在利用 Profiler 代理来启动 VM 之前,调用此任务。

一般情况下,该任务不是手动启动的,而是通过 Profiler 的用户界面操作“分析项目”或“分析文件”启动的,但是在某些特殊情况下,您也可以手动调用它(不过,仍需要在 NetBeans IDE 的环境中调用)。

如果调用该任务时,上下文环境不够充分;或者指定了 interactive 属性,则首先会显示一个对话框,用户可以在其中选择性能分析的类型。

参数

属性 描述 必需
mainclass 要执行的 Java 类。 Jar 或类名
jvmargsproperty 用来指定应该在哪个属性中存储用于启动 Profiler 代理的 JVM 参数。缺省值为 profiler.info.jvmargs.agent。当成功完成 nbprofiledirect 后,该属性将包含应传递给分析的 JVM 的 JVM 参数。
jvmargsprefix 用来指示 Profiler 在创建 Profiler 代理 JVM 参数时使用特定的前缀。这对 NetBeans IDE 性能分析示例非常有用,在示例中,应传递给 VM 的参数具有 -J 前缀。
jvmproperty 用来指定应该在哪个属性中存储用于性能分析的 JVM。缺省值为 profiler.info.jvm。成功完成 nbprofiledirect 后,该属性将包含用于性能分析的 JVM 的路径。
interactive autotruefalse。控制在调用该任务时是否显示“选择性能分析任务”。缺省值为 auto,这意味着如果采用了不充分的属性上下文环境来调用 nbprofiledirect,则会显示该对话框。正常情况下,通过“分析项目”或“分析文件”操作正确地调用该任务时,不会显示该对话框。

指定为嵌套元素的参数

classpath

Javaclasspath 属性是一种类似于路径的结构,您还可以通过嵌套的 classpath 元素对其进行设置。

rootspath

这是一种类似于路径的结构,可用于指定 Profiler 应将其视为属于项目的包。如果使用该参数,CPU 性能分析将只分析从这些包的方法中调用的代码。该参数在应用服务器中尤为有用,如果在其中指定只分析某些包的用户代码,则会大大降低性能分析的开销。

错误和返回代码

示例

在自由格式项目中使用 nbprofiledirect 的一种典型方法是:

        <nbprofiledirect>
          <classpath>
            <pathelement location="dist/test.jar"/>
            <pathelement path="${java.class.path}"/>
          </classpath>
        </nbprofiledirect>

        <java classname="org.mytest.Main" jvm="${profiler.info.jvm}">
          <classpath>
            <pathelement location="dist/test.jar"/>
            <pathelement path="${java.class.path}"/>
          </classpath>
          <jvmarg value="${profiler.info.jvmargs.agent}"/>
        </java>

在交互模式下使用 nbprofiledirect 的示例:

        <nbprofiledirect interactive="true" jvmargsproperty="my.agent.property">
          <classpath>
            <pathelement location="dist/test.jar"/>
            <pathelement path="${java.class.path}"/>
          </classpath>
        </nbprofiledirect>
        <java classname="org.mytest.Main" jvm="${profiler.info.jvm}">
         <classpath>
           <pathelement location="dist/test.jar"/>
           <pathelement path="${java.class.path}"/>
         </classpath>
         <jvmarg value="${my.agent.property}"/>
        </java>

 

 

Project Features

About this Project

Profiler was started in November 2009, is owned by Tomas Hurka, and has 41 members.
 
 
Close
loading
Please Confirm
Close