J
jlp
The String class was modified in JDK 1.7.0_6.
String.substring that was 0(1) before JDK 1.7.0_6, now becomes O(n)
All is well explained at :
http://java-performance.info/changes-to-string-java-1-7-0_06/
I wrote a small test:
https://gist.github.com/4692960
java -Xms128M -Xmx128M teststring.Main 100000 1000000
On my desktop:
jdk 1.7.0_11 => 33 seconds / 252 KBytes Memory
jdk 1.6.0_38 => 25 milliseconds / 782 KBytes Memory
more than 1000 times faster ! ( Ok! for this stupid test ;-) )
I don't think it is a good improvement ! Uses less memory, but you
retrieve it, when the object is garbaged
What do you think about this ?
String.substring that was 0(1) before JDK 1.7.0_6, now becomes O(n)
All is well explained at :
http://java-performance.info/changes-to-string-java-1-7-0_06/
I wrote a small test:
https://gist.github.com/4692960
java -Xms128M -Xmx128M teststring.Main 100000 1000000
On my desktop:
jdk 1.7.0_11 => 33 seconds / 252 KBytes Memory
jdk 1.6.0_38 => 25 milliseconds / 782 KBytes Memory
more than 1000 times faster ! ( Ok! for this stupid test ;-) )
I don't think it is a good improvement ! Uses less memory, but you
retrieve it, when the object is garbaged
What do you think about this ?