7 Mayıs 2021 Cuma

hprof Profiling

Giriş
Söz dizimi şöyle
java -agentlib:hprof[=options] ToBeProfiledClass
java -Xrunprof[:options] ToBeProfiledClass
javac -J-agentlib:hprof[=options] ToBeProfiledClass
Options için açıklama şöyle
Option Name and Value  Description                    Default
---------------------  -----------                    -------
heap=dump|sites|all    heap profiling                 all
cpu=samples|times|old  CPU usage                      off
monitor=y|n            monitor contention             n
format=a|b             text(txt) or binary output     a
file=<file>            write data to file             java.hprof[.txt]
net=<host>:<port>      send data over a socket        off
depth=<size>           stack trace depth              4
interval=<ms>          sample interval in ms          10
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
msa=y|n                Solaris micro state accounting n
force=y|n              force output to <file>         y
verbose=y|n            print messages about dumps     y
cpu seçeneği
Örnek - samples
Şöyle yaparız
java -agentlib:hprof=cpu=samples,interval=20,depth=20 -jar target.jar
Örnek - samples
Şöyle yaparız
java -agentlib:hprof=cpu=samples,interval=20,depth=3 Hello
Açıklaması şöyle
The CPU consumption information is sampled every 20 milliseconds, the stack depth is 3, and the name of the generated profile file is java.hprof.txt, which is in the current directory.
Örnek - times
Şöyle yaparız
javac -J-agentlib:hprof=cpu=times Hello.java
Açıklaması şöyle
An example of CPU Usage Times Profiling (cpu=times), which can obtain more fine-grained CPU consumption information than CPU Usage Sampling Profile, and can be detailed to the beginning and end of each method call. Its implementation uses bytecode injection Technology (BCI):
heap seçeneği
Örnek - sites
Şöyle yaparız
javac -J-agentlib:hprof=heap=sites Hello.java
Açıklaması şöyle
Example of Heap Allocation Profiling (heap=sites):
Açıklaması şöyle
Although the -Xrunprof:heap=sites parameter can be added to the JVM startup parameters to generate the CPU/Heap Profile file, but it has a great impact on the performance of the JVM, and it is not recommended to use it in an online server environment.
Örnek - dump
Şöyle yaparız
javac -J-agentlib:hprof=heap=dump Hello.java
Açıklaması şöyle
An example of Heap Dump(heap=dump), which can generate more detailed Heap Dump information than the above Heap Allocation Profiling:





Hiç yorum yok:

Yorum Gönder