读书人

java2e performance guides的1点疑问

发布时间: 2012-12-18 12:43:41 作者: rapoo

java2e performance guides的一点疑问


这段代码在文章中给出的结果为:
Time taken for creation of String literals : 0 milli seconds
Time taken for creation of String objects with 'new' key word : 160 milli seconds
Time taken for creation of String objects with intern(): 60 milli seconds
但是我在电脑上实际运行结果为:
Time taken for creation of String literals : 0 milli seconds
Time taken for creation of String objects with 'new' key word : 3 milli seconds
Time taken for creation of String objects with intern(): 7 milli seconds
刨除硬件运行速度差异,明显区别还是String.intern()执行到底有没有带来效率上的提高.似乎我的运行结果与作者要说明的事实恰恰相反.

读书人网 >编程

热点推荐