Java 在 IntelliJ IDEA 中检查运行时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1210081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Checking Run time in IntelliJ IDEA
提问by Eran
How can I see how much time it took for the code to run in InteliJ?
如何查看代码在 InteliJ 中运行所需的时间?
采纳答案by Jon
I don't think you can with Intellij, you either have to use a profiler like Yourkitto profile the code or use some primitive benchmarks using System.currentTimeInMillis(). Alternatively you can use Apache Commons StopWatchto do some benchmarking:
我认为您不能使用 Intellij,您要么必须使用像Yourkit这样的分析器来分析代码,要么使用System.currentTimeInMillis()使用一些原始基准。或者,您可以使用Apache Commons StopWatch进行一些基准测试:
StopWatch stopwatch = new StopWatch();
stopwatch.start();
... some code...
stopwatch.stop();
long timeTaken = stopWatch.getTime()
EDIT: There is a plugin available for Intellij that uses VisualVM to do profiling, you could install this as another alternative.
编辑:有一个可用于 Intellij 的插件,它使用 VisualVM 进行分析,您可以将其安装为另一种选择。