zoukankan      html  css  js  c++  java
  • java命令行HPROF Profiler(转)

    The HPROF Profiler

    The Heap and CPU Profiling Agent (HPROF)是JAVA2 SDK自带的一个简单的profiler代理,它通过与Java Virtual Machine Profiler Interface (JVMPI) 交互,将profiling信息通过本地文件或socket输出ASCII或二进制格式的流。

    HPROF可以监控CPU使用率,堆分配统计。除此之外,还可以报告JVM所有监视器和线程的完整的堆的dump状态。

    HPROF的JVM参数的语法如下:

    -Xrunhprof[:help]|[:param=value,param2=value2, ...]

    示例:

    -Xrunhprof:file=log.txt,thread=y,depth=3

    The file parameter determines where the stack dump is written.

    file参数决定dump的堆栈写入到那个文件。

    HPROF的详细参数如下:

    复制代码
    Hprof usage: -Xrunhprof[:help]|[:<option>=<value>, ...]
    
    Option Name and Value   Description             Default
    ---------------------   -----------             -------
    heap=dump|sites|all     heap profiling          all
    cpu=samples|old         CPU usage               off
    format=a|b              ascii or binary output  a
    file=<file>             write data to file      java.hprof
                                   (.txt for ascii)
    net=<host>:<port>       send data over a socket write to file
    depth=<size>            stack trace depth       4
    cutoff=<value>          output cutoff point     0.0001
    lineno=y|n              line number in traces?  y
    thread=y|n              thread in traces?       n
    doe=y|n                 dump on exit?           y
    复制代码

    一个javac的示例

    复制代码
    Command used: javac -J-agentlib:hprof=cpu=samples Hello.java
    
    CPU SAMPLES BEGIN (total = 126) Fri Oct 22 12:12:14 2004
    rank   self  accum   count trace method
       1 53.17% 53.17%      67 300027 java.util.zip.ZipFile.getEntry
       2 17.46% 70.63%      22 300135 java.util.zip.ZipFile.getNextEntry
       3  5.56% 76.19%       7 300111 java.lang.ClassLoader.defineClass2
       4  3.97% 80.16%       5 300140 java.io.UnixFileSystem.list
       5  2.38% 82.54%       3 300149 java.lang.Shutdown.halt0
       6  1.59% 84.13%       2 300136 java.util.zip.ZipEntry.initFields
       7  1.59% 85.71%       2 300138 java.lang.String.substring
       8  1.59% 87.30%       2 300026 java.util.zip.ZipFile.open
       9  0.79% 88.10%       1 300118 com.sun.tools.javac.code.Type$ErrorType.<init>
      10  0.79% 88.89%       1 300134 java.util.zip.ZipFile.ensureOpen
    复制代码

    参考 http://docs.oracle.com/cd/E19798-01/821-1752/beafo/index.html

           http://stackoverflow.com/questions/11737013/java-profile-tool-without-gui

    http://www.cnblogs.com/ggjucheng/p/3352332.html

  • 相关阅读:
    夜半饮酒
    邀你到成都来
    成都,我的天堂
    真不想松开你的手
    创业,你懂如何求人办事么?
    只要你愿意
    【五月的歌】重振山河
    成都,我爱你
    就算忘了自己也忘不了你
    假如
  • 原文地址:https://www.cnblogs.com/softidea/p/5274878.html
Copyright © 2011-2022 走看看