"野马"的VM

今天是06年的第一天,我居然还是要无聊到写BLOG,哎~长象问题啊~没人陪!
今天无意中看了下Java6.0 ,代号"野马"。难道sun这回在寓意java的执行速度???
管他的先下回来看看先
java6.0Releases
http://download.java.net/jdk6/binaries/
很快就装好了,于是按老习惯写了个测试程序,看看是不是匹"野马"呵呵

public class Main {    
public static void main(String[] args) {
// TODO code application logic here String strTest="";
double t1=System.currentTimeMillis();
for(int i=0;i<=5000;i++)
strTest
+="Demo"+i;
double t2=System.currentTimeMillis();
System.out.print(t2
-t1);
}
}
上面这段主要是测试字符串累加/装箱,5000个对象还可以测试GC收集的速度.
好了不多说 直接执行

java 1.5
javac Main.java
java Main
output: 4532

java 1.6
javac Main.java
java Main
output: 2342


呵呵,没错居然块了差不多一半 ,看来还真是一匹"野马".
但是如果用java 1.6 的javac 后 用1.5的java来执行则会报错!
不会是不向下兼容把,因该不会这样,可能在正式版会得到改进

java 1.6VM
java从1.5版开始就内置了2种配置情况的VM
Java HotSpot Client VM(The client VM is tuned for reducing start-up time and memory footprint)
Java HotSpot Server VM(The server VM is designed for maximum program execution speed)

当然可以在java加载程序的时候,来指定要使用的VM
比如(注意都是小写)
java -client Main
java -server Main
各平台默认VM
Platform
Default VM
ArchitectureOS
client VM
if server-class, server VM;
otherwise, client VM
server VM
SPARC 32-bitSolaris
 
X
 
i586Solaris
 
X
 
Linux
 
X
 
Microsoft Windows
X
 
 
SPARC 64-bitSolaris
 
X
AMD64Linux
 
X
Microsoft Windows
 
X
Legend:    = 默认 VM      — = 没有 client VM 
Note: For J2SE 5.0, the definition of a server-class machine is one with at 
least 2 CPUs and at least 2GB of physical memory.
(从j2se1.5开始,只有至少2颗CPU和至少2G内存的及其才定义为服务器机器)
另外,"野马"中VM还增加了3个特色:
Adaptive compiler(合适的编译器) - Applications are launched using a standard 
interpreter, but the code is then analyzed as it runs to detect performance
bottlenecks, or "hot spots". The Java HotSpot VMs compile those performance-critical
portions of the code for a boost in performance, while avoiding unnecessary
compilation of seldom-used code (most of the program). The Java HotSpot VMs
also use the adaptive compiler to decide, on the fly, how best to optimize
compiled code with techniques such as in-lining. The runtime analysis
performed by the compiler allows it to eliminate guesswork in determining
which optimizations will yield the largest performance benefit.

Rapid memory(高速内存) allocation and garbage collection - Java HotSpot technology
provides for rapid memory allocation for objects, and it offers a choice
of fast, efficient, state-of-the-art garbage collectors.

Thread synchronization(同步线程) - The Java programming language allows for use of
multiple, concurrent paths of program execution (called "threads").
Java HotSpot technology provides a thread-handling capability that is
designed to scale readily for use in large, shared-memory multiprocessor
servers

看来Sun也开始模仿MSJIT技术拉,不错从开头的那段程序我们就能看的出来~
不过有竞争才是好事,那样才能促使技术的进步!



阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页