简体   繁体   English

在 IntelliJ IDEA Ultimate 中检查运行时间

[英]Checking Run time in IntelliJ IDEA Ultimate

我可以使用 InteliJ Ultimate 的分析器来查看执行一个方法需要多长时间吗?

Two particularly helpful tools for examining the program at runtime are the debugger and profilers.在运行时检查程序的两个特别有用的工具是调试器和分析器。

The debugger is very precise and gives you full and granular control over the execution of the program, which allows you to reproduce intricate failure conditions.调试器非常精确,可让您全面细致地控制程序的执行,从而可以重现复杂的故障情况。

The profiler, on the other hand, offers a bird's eye view of arbitrarily large execution chunks.另一方面,分析器提供了任意大的执行块的鸟瞰图。 It does not interfere with the running program, nor does it provide granular data as the debugger does.它不会干扰正在运行的程序,也不会像调试器那样提供粒度数据。 However, it can collect valuable information.但是,它可以收集有价值的信息。

Java Flight Recorder – a standard profiling tool shipped as part of the JDK. Java Flight Recorder – 作为 JDK 的一部分提供的标准分析工具。

Async Profiler - a very accurate profiler that can also collect native call and memory allocation data. Async Profiler - 一个非常准确的分析器,还可以收集本机调用和内存分配数据。

You can read more details on Jetbrains profiling tools您可以阅读有关Jetbrains 分析工具的更多详细信息

There are plugins as well for Intellij to do profiling, check on File -> Settings -> Plugins and search for Java profiler. Intellij 也有插件可以进行分析,检查File -> Settings -> Plugins并搜索 Java 分析器。 For instance check JProfiler .例如检查JProfiler

Of course, you can use tools for benchmark calculation as Apache Commons StopWatch , which provides a convenient API for timings.当然,您可以使用Apache Commons StopWatch 等基准计算工具,它提供了一个方便的计时 API。

StopWatch watch = new StopWatch();
watch.start();
...
watch.stop();
System.out.println(watch.getTime());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM