跳转到内容
彼岸论坛
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[程序员] 在 idea 中执行与在命令行执行,速度怎么相差这么大


小天管理

已推荐帖子

public class Main {
public static void main(String[] args) {
long startTime = System.nanoTime();
long startTime2 = System.currentTimeMillis();
for (int i = -1; ++i < 1000; ) {
String row = "Column 1: " + "1" + ", Column 2: " + "2" +
", Column 3: " + "3" + ", Column 3: " + "4";
System.out.println(row);
}
long endTime = System.nanoTime();
long endTime2 = System.currentTimeMillis();

long durationInMillis = (endTime - startTime) / 1_000_000;
long durationInMillis2 = (endTime2 - startTime2) / 1;
System.out.println("Time taken to output the result: " + durationInMillis + " milliseconds");
System.out.println("Time taken to output the result: " + durationInMillis2 + " milliseconds");
}
}


idea
点击运行

Time taken to output the result: 6 milliseconds
Time taken to output the result: 6 milliseconds


cmd 命令提示符
java Main.java

Time taken to output the result: 143 milliseconds
Time taken to output the result: 145 milliseconds
意见的链接
分享到其他网站

加入讨论

您现在可以发表并稍后注册. 如果您是会员,请现在登录来参与讨论.

游客
回复主题...

×   粘贴为富文本.   粘贴为纯文本来代替

  只允许使用75个表情符号.

×   您的链接已自动嵌入.   显示为链接来代替

×   您之前的内容已恢复.   清除编辑器

×   您无法直接粘贴图片.要从网址上传或插入图片.

  • 游客注册

    游客注册

  • 会员

    没有会员可显示

  • 最新的状态更新

    没有最新的状态更新
  • 最近查看

    • 没有会员查看此页面.
×
×
  • 创建新的...