Java is used either for long running server side applications / application servers or for running short scripts. Java是使用,也可以為長時間運行的服務器端的應用/應用服務器或開辦短期的腳本。 Let’s look at how you can speed-up both these type of applications.讓我們看看你如何能加快行動這兩類型的申請。


How to speed-up server-side Java applications如何加快後續服務器端的Java應用程序

It is very simple really.這是很簡單,真的。 Just add -server after the java command like this:剛剛添加服務器後, Java的命令是這樣的:
java -server HelloWorld Java服務器的HelloWorld

Replace HelloWorld with your application name.取代的HelloWorld與您的應用程式名稱。 That wasn’t so hard was it?這不是辛苦是它呢?

How to speed-up client-side Java applications如何加快跟進客戶端的Java應用程序

Download下載 and install nailgun.並安裝nailgun 。 You may want to read the您可能想要閱讀 quickstart guide快速入門指南 for details.詳情。

Nailgun is a simple application server which allows you to run Java programs rapidly through the server instance. nailgun是一個簡單的應用服務器,它可以讓您運行Java程序迅速通過服務器實例。 The nailgun client (ng for linux and ng.exe for windows) is a small c program which works on both windows and linux platforms.該nailgun客戶端(靄儀議員為Linux和ng.exe適用於Windows )是一個很小的C語言程序,其中工程對Windows及Linux平台。 To run Java applications you just have to substitute ng (assuming it is in path) for java.運行Java應用程序你一定要以靄儀議員(假設它是在路徑)的Java 。 ng reduces startup time by running programs from the same instance.靄儀議員減少啟動時間由正在運行的程序來自同一實例。 However it uses socket connection for communication which can be further optimized.不過,它使用套接字連接溝通,可以進一步優化。
Let’s see how much ng improves the performance for simple client side applications.讓我們看看有多少靄儀議員,提高了性能,簡單的客戶端應用。

Here is a simple HelloWorld program I ran using java:這裡是一個簡單的HelloWorld程序我運行用Java :

 [angsuman@jaguar project]$ time java HelloWorld Hello World! [由Angsuman @捷豹項目]元,時間的Java的HelloWorld世界您好! real    0m0.107s user    0m0.049s sys     0m0.012s真正的0m0.107s用戶0m0.049s系統0m0.012s 

Here is the same program run using nailgun:這裡是相同的程序運行使用nailgun :

 [angsuman@jaguar project]$ time ../software/nailgun-0.7.1/ng HelloWorld Hello World! [由Angsuman @捷豹項目]元,時間../software/nailgun-0.7.1/ng的HelloWorld世界您好! real    0m0.002s user    0m0.000s sys     0m0.001s真正的0m0.002s用戶0m0.000s系統0m0.001s 

Can you see the difference?你能看到的差別?

Here is the result of running helloworld in C (compiled with gcc):在這裡,是由於運行的HelloWorld在C (彙編與海灣合作委員會) :

 [angsuman@jaguar project]$ time ./hello Hello World! [由Angsuman @捷豹項目]美元的時間。 /您好世界您好! real    0m0.001s user    0m0.001s sys     0m0.001s真正的0m0.001s用戶0m0.001s系統0m0.001s 

I am using:我使用的:

 [angsuman@jaguar project]$ java -version java version “1.6.0_01″ Java(TM) SE Runtime Environment (build 1.6.0_01-b06) Java HotSpot(TM) Server VM (build 1.6.0_01-b06, mixed mode) [由Angsuman @捷豹項目]美元的Java版Java版“ 1.6.0_01 ”的Java (技術備忘錄)本身的運行時間環境(建立1.6.0_01 - b06 ) Java的熱點(技術備忘錄)服務器的越南船民(建設1.6.0_01 - b06 ,混合模式) 

The Java code is: Java代碼是:

 public class HelloWorld {   public static void main(String args[]) {      System.out.println("Hello World!");   } }市民階層的HelloWorld (公共靜態無效的主要(字符串args [ ] ) ( system.out.println ( “世界您好! ” ) ; ) ) 

The c code is: C代碼是:

 #include #包括  int main(void) {         printf(”Hello World!\n”); }詮釋主體(無效) ( printf ( “世界您好! \ n ” ) ; ) 

Let’s finally put to rest the myth that “讓我們最後付諸表決,休息的神話“ Java is slow Java是緩慢 “. “ 。