Java对象实例化的速度的一个试验

Java Console 程序 循环59999999次

点评在先:1方法永远不要这样实例化String.2和3方法速度差距不大但是3方法更抽象利于拓展.4方法用来参考

1, 

String s1 = new String("jiiyou");
String s2 = new String("jiiyou");
int i1 =1000;
int i2 =1000;============================>2300ms    

2,

BGBL bgbl = new BGBL("jiiyou",6000);
DJWX djwx = new DJWX("jiiyou",6000);==========================>1200ms

3,

Good good = new Good("jiiyou",6000);
BGBL bgbl = new BGBL(good);
DJWX djwx = new DJWX(good);=============================>1600ms

4,

BGBL bgbl = new BGBL(new Good("jiiyou",6000));
DJWX djwx = new DJWX(new Good("jiiyou",6000));==================>2000ms

 

5,

String s1 = "jiiyou";
String s2 = "jiiyou";
int i1 =1000;
int i2 =1000;============================>350ms    

posted @ 2013-05-28 18:49  linsen@java  阅读(479)  评论(0编辑  收藏  举报