Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collection framework built into the Oracle JDK. It allows Java administrators and developers to gather detailed low level information about how the Java Virtual Machine (JVM) and the Java application are behaving. Java Mission Control is an advanced set of tools that enables efficient and detailed analysis of the extensive of data collected by Java Flight Recorder. The tool chain enables developers and administrators to collect and analyze data from Java applications running locally or deployed in production environments.
Java Flight Recorder和Java Mission Control共同创建了一个完整的工具链,以连续收集低水平和详细的运行时信息,从而进行事后事件分析。 Java Flight Recorder是Oracle JDK中内置的概要分析和事件收集框架。 它允许Java管理员和开发人员收集有关Java虚拟机(JVM)和Java应用程序行为方式的详细底层信息。 Java Mission Control是一组高级工具,可对Java Flight Recorder收集的大量数据进行高效,详细的分析。 该工具链使开发人员和管理员可以从本地运行或部署在生产环境中的Java应用程序收集和分析数据。
The Java Flight Recorder does not trace every function call that gets executed. Instead, it "samples" the application at regular intervals, collecting stack trace information about each thread being executed. So if you're looking for how many times a certain function is being called, or how much total time is spent executing a certain method, you're not going to find that kind of information. However, by analyzing the samples taken, you can still determine where your application is spending most of its time.
Java Flight Recorder不会跟踪每个执行的函数调用。 而是定期对应用程序进行“采样”,收集有关正在执行的每个线程的堆栈跟踪信息。 因此,如果要查找某个函数的调用次数或执行某个方法所花费的总时间,则不会找到这种信息。 但是,通过分析样本,您仍然可以确定应用程序大部分时间都花在了哪里。
We'll assume, at this point, that Java 8 and Eclipse are already installed. If they are not, they can be found at the following locations:
此时,我们假定已经安装了Java 8和Eclipse。 如果不是,则可以在以下位置找到它们:
Once that's complete, create a simple java application that could use some optimization:
完成后,创建一个可以使用一些优化的简单Java应用程序:
public static void main(String[] args)
{
// These values may need to change depending upon the speed of your machine.
// You want this app to run for approximately 60 seconds to get usable results
final int outerIterations = 1000;
final int innerIterations = 10000;
for (int outer = 0; outer < outerIterations; outer++)
{
StringBuilder message = new StringBuilder();
for (int inner = 0; inner < innerIterations; inner++)
{
message.append(inner);
}
System.out.println(message);
}
}
Create a Run Configuration for the java application:
为Java应用程序创建运行配置:
Make sure the following two options are checked:
确保选中以下两个选项:
Now run the application using the Run configuration. Once the application is finished, and the flight recording is open, we can see a lot of information about the running application.
现在,使用“运行”配置运行应用程序。 一旦应用程序完成,并且飞行记录已打开,我们就可以看到有关正在运行的应用程序的许多信息。