Bu Blogda Ara

22 Şubat 2010 Pazartesi

Java HotSpot VM: -server vs -client

You can find a lot of web-sites about Java HotSpot VM. As you may know there are two binary-distributions of JVM: Server JVM and Client JVM.
Differences between them is, Server JVM is best suited for long running server-side applications, and tuned for maximizing operating speed. On the other hand Client JVM is tuned for client-side applications and more memory-friendly. Until now everything is ok.

I have a question. On which side xml – data is process more? On server side or client side? I guess you will reply as “of course in server side”.

However, although server-side applications are processing xml-data more often than client-side applications, and although Server JVM is claimed to be more suitable for server-side applications, Client JVM performing two times better than Server JVM in xml processing. Surprising isn’t it?

You can check what I am claiming by running following code with two jmv options: -server, -client:


import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;

public class Test {

public static void main(String[] args) throws InterruptedException {
String xmlData = //read from file

int count = 999;
long start, stop;

start = System.currentTimeMillis();
for(int i=0; i newDocument(xmlData );
}
stop = System.currentTimeMillis();
System.out.println
("\n-- Elapsed Time for echo1: " + (stop - start));

}

public static Document newDocument(String message) {
Document doc = null;
try {
doc = DocumentHelper.parseText(message);
} catch (DocumentException e) {
e.printStackTrace();
}
return doc;
}
}

Thanks for reading
Aydın Karaman

Hiç yorum yok:

Yorum Gönder