search

Home  >  Q&A  >  body text

java - JProfiler:关于使用工具查看CPU占用情况

Student.java

public class Student {
}

Client.java

public class Client {
    public static void main(String[] args) {
        while (true) {
            try {
                Thread.sleep(1000);
                new Student(); // 创建对象
                System.out.println("Working...");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

在 Call Tree 中直接就100%了,比较费解这段代码这么占CPU呢?

查看了官方文档也没具体介绍这里显示的是什么,只是说CPU,而且这里有浅红色、深红色两种颜色,有用过JProfiler的知道为啥占用情况这么高吗?

大家讲道理大家讲道理2892 days ago392

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:19:45

    JProfiler provides different methods to record access trees to optimize performance and detail. Threads or thread groups and thread status can be selected in all views. All views can be aggregated into different layers such as methods, classes, packages or J2EE components. The CPU view section includes four parts:
    Access Tree Call Tree
    Displays an accumulated top-down tree that contains all access queues that have been recorded in the JVM. JDBC, JMS and JNDI service requests are all annotated in the request tree. The request tree can be split based on the different needs of Servlets and JSPs for URLs.
    Hot Spots
    Shows a list of methods that consume the most time. A traceback tree can be displayed for each hotspot. The hotspot can be calculated per method request, JDBC, JMS and JNDI service request and per URL request.
    Call Graph
    Displays a graph of the access queue starting from the selected method, class, package or J2EE component.
    Method Statistics
    Displays the call time details of methods recorded over a period of time.

    So, what you 100% represent is: Access Tree Call Tree, showing an accumulated top-down tree, which contains all access queues that have been recorded in the JVM. JDBC, JMS and JNDI service requests are all annotated in the request tree. The request tree can be split based on the different needs of Servlets and JSPs for URLs.

    reply
    0
  • Cancelreply