在IntelliJ IDEA中检查运行时间 [英] Checking Run time in IntelliJ IDEA

查看:2757
本文介绍了在IntelliJ IDEA中检查运行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查看在InteliJ中运行代码需要花费多少时间?

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

推荐答案

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

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:

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

Intellij有一个可用VisualVM进行性能分析的插件,您可以将其安装为另一种选择.

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

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

这篇关于在IntelliJ IDEA中检查运行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆