有没有办法减少控制台Java应用程序的启动时间? [英] Is there a way to reduce startup time of a console Java application?

查看:213
本文介绍了有没有办法减少控制台Java应用程序的启动时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,在Java中最小控制台应用程序的启动时间在我的机器上比在等同的C应用程序的1毫秒稍微超过100毫秒。虽然在大多数情况下它不是一个问题,我想知道是否有一种方法来减少这个时间,因为我需要编写一个应用程序将执行多次(例如在一个循环的bash脚本)。


I noticed that the startup time of a minimal console application in Java is slightly more than 100 ms on my machine compared to 1 ms of an equivalent C application. Although it is not a problem in most cases I would like to find out if there is a way to reduce this time because I need to write an application that will be executed many times (say in a loop within a bash script).

推荐答案

你要求的是Achilles的脚跟。真的没有太多的事情。最后一个Java版本将是最高性能的,他们在该问题上工作多年。 / a>。

You asking for the "Achilles' heel" of Java. There is really not much to do with it. The last Java version will be the most performant, they are working for years on that issue.

无论如何,运行同一个程序几次,你会注意到,第一次启动后,下一个更快。我认为这来自操作系统缓存机制。

Anyway running the same program several times you will notice that after first startup the next is much more faster. I think that comes from the OS caching mechanism.

让它更好的唯一真正的方法是让你的应用程序在后台运行,并与您的应用程序通信通过一个Web服务(这是什么servlet容器是所有)。

The only real way to make it better is to let run your app in background and comunicate with your app maybe thru a web service (that is what servelet container is all about).

100毫秒听起来太多,但在您的情况下可能无法接受。

100ms not sounds too much but could be unacceptable in your case.

这篇关于有没有办法减少控制台Java应用程序的启动时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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