在IntelliJ IDEA中检查运行时

时间:2021-07-30 20:23:25

How can I see how much time it took for the code to run in InteliJ?

我怎样才能看到代码在InteliJ中运行需要多长时间?

1 个解决方案

#1


12  

I don't think you can with Intellij, you either have to use a profiler like Yourkit to profile the code or use some primitive benchmarks using System.currentTimeInMillis(). Alternatively you can use Apache Commons StopWatch to do some benchmarking:

我不认为您可以使用Intellij,您必须使用像Yourkit这样的分析器来分析代码或使用System.currentTimeInMillis()使用一些原始基准。或者,您可以使用Apache Commons StopWatch进行一些基准测试:

StopWatch stopwatch = new StopWatch();
stopwatch.start();
... some code...
stopwatch.stop();
long timeTaken = stopWatch.getTime()

https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/time/StopWatch.html

https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/time/StopWatch.html

EDIT: There is a plugin available for Intellij that uses VisualVM to do profiling, you could install this as another alternative.

编辑:Intellij有一个插件可以使用VisualVM进行分析,你可以安装它作为另一种选择。

http://plugins.intellij.net/plugin/?id=3749

http://plugins.intellij.net/plugin/?id=3749

#1


12  

I don't think you can with Intellij, you either have to use a profiler like Yourkit to profile the code or use some primitive benchmarks using System.currentTimeInMillis(). Alternatively you can use Apache Commons StopWatch to do some benchmarking:

我不认为您可以使用Intellij,您必须使用像Yourkit这样的分析器来分析代码或使用System.currentTimeInMillis()使用一些原始基准。或者,您可以使用Apache Commons StopWatch进行一些基准测试:

StopWatch stopwatch = new StopWatch();
stopwatch.start();
... some code...
stopwatch.stop();
long timeTaken = stopWatch.getTime()

https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/time/StopWatch.html

https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/time/StopWatch.html

EDIT: There is a plugin available for Intellij that uses VisualVM to do profiling, you could install this as another alternative.

编辑:Intellij有一个插件可以使用VisualVM进行分析,你可以安装它作为另一种选择。

http://plugins.intellij.net/plugin/?id=3749

http://plugins.intellij.net/plugin/?id=3749