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

java命令行HPROF Profiler(转)的更多相关文章

  1. java命令行HPROF Profiler

    The HPROF Profiler The Heap and CPU Profiling Agent (HPROF)是JAVA2 SDK自带的一个简单的profiler代理,它通过与Java Vir ...

  2. Java命令行的基本编译运行

    1.编译 编写MyProgram.java文件,内容如下: public class MyProgram { public static void main(String[] args) { Syst ...

  3. Linux java 命令行编译 jar包

    Java 命令行编译成class,然后在打包成jar文件. 编译成class javac -classpath $CLASS_PATH -d class ./src/Hello.java 可以通过ja ...

  4. java命令行执行程序解决依赖外部jar包的问题

    用java命令行直接执行程序,如果这个程序需要引用外部jar包.就不能单纯用java xx来执行 如果你的jar包和程序就在一个目录: 编译 javac -cp D:\yy\yy.jar,D\xx\x ...

  5. java命令行打war

    java命令行打war(windows下) 切换到需要打包文件夹low的上级目录>jar -cfM legendwealth.war -C low .

  6. Java 命令行编译项目

    如果是用Exlipse, 第三方的包可以放在eclipse文件夹的jre包的lib文件夹中! (初学者的一些总结-高手们勿喷哈-) 原因: 以前一直用Eclispe编程环境运行Java.非常舒服,就像 ...

  7. java命令行从编译到打jar包到执行

     目录: 一. javac编译     1. 没有额外的jar包     2. 包含额外的jar包 二. jar打jar包 三. java运行     1. java命令执行     2. jar包执 ...

  8. Java - Java 命令行简介: 选项, 属性, 参数

    概述 简单介绍一下 java 命令行相关的参数及属性 1. java 命令行 基本 命令 > java <mainClass> 描述 执行 Java 类 需要准备好编译完成的 mai ...

  9. java命令行输入参数

    Java命令行输入参数 代码用例:命令行输入参数,并进行加法运算. public class Demo01 { public static void main(String[] args) { for ...

随机推荐

  1. php获取server端mac和clientmac的地址

    获取servermac <?php /** 获取网卡的MAC地址原码:眼下支持WIN/LINUX系统 获取机器网卡的物理(MAC)地址 **/ class GetmacAddr{ var $re ...

  2. Lambda高手之路第一部分

    转http://www.cnblogs.com/lazycoding/archive/2013/01/06/2847574.html 介绍 Lambda表达式是使代码更加动态,易于扩展并且更加快速(看 ...

  3. 多项式相乘(C语言)

    //两个多项式的系数f分别存在x[]和y[]中,下标即为次数,*Max表示本多项式最高次数 int MX_double( double x[], int xMax, double y[], int y ...

  4. linux find命令强大之处

    find命令 find pathname -options [-print -exec -ok ...]   -print: find命令将匹配的文件输出到标准输出.   -exec: find命令对 ...

  5. [cocos2d-x]屏幕自适应解决的方法

    近期在写一个项目,要求pc,ipad,andriod平台上都能够执行,所以选择用cocos2d-x来开发. 我们的资源大小是1024*768的,在pc上和苹果上都是没有问题的,但是到了andriod上 ...

  6. linux进程通信之信号

    本节主要学习信号和与信号相关的处理函数,兴许还会更新. http://blog.csdn.net/xiaoliangsky/article/details/40264151 一 信号 信号是UNIX和 ...

  7. 陈词滥调,正确使用memset

    前项目发现一个问题,计划永远是一个dynamic_cast当一个异常动态转换,搜索了半天才发现问题竟然是在memset使用,见.但当处于几十万行代码量级中时,就变得不太那么easy定位了. 本文归纳了 ...

  8. loj1341(数学)

    传送门:Aladdin and the Flying Carpet 题意: 给出两个正整数1<=m<=n<=1e12.问N可以拆成多少对p*q,使得p和q中最小的不小于a,且p!=q ...

  9. python(abi) RPM DEB Download

    python(abi) RPM DEB Download python(abi) RPM DEB Download

  10. 不错的C++框架: Thrift(2)-传输和网络相关

    不错的C++框架: Thrift(2)-传输和网络相关 - ang639 - 博客频道 - CSDN.NET 不错的C++框架: Thrift(2)-传输和网络相关