Benchmark for java.nio.charset.Charset cache

Ulf Zibis Ulf.Zibis at gmx.de
Tue Oct 13 13:55:50 UTC 2009


Hi, Martin, Xueming,

I did a benchmark:
     unsynchronized 2-ElementCache ./. synchronized 4-ElementCache

Result:
Usage: java -Xint 
-Xbootclasspath/p:..\build\classes;..\build\test\classes 
java.nio.charset.CharsetBenchmark
       As in real world, excessive loops on Charset.forName() are 
unlikely, only use interpreter mode here!
Benchmark for 100000 from 1 charsets:
- time of unsynchronized 2-ElementCache: 40 + 42 = 82 ms
- time of   synchronized 4-ElementCache: 48 + 49 = 97 ms
Benchmark for 100000 from 2 charsets:
- time of unsynchronized 2-ElementCache: 83 + 90 = 173 ms
- time of   synchronized 4-ElementCache: 138 + 110 = 248 ms
Benchmark for 100000 from 3 charsets:
- time of unsynchronized 2-ElementCache: 801 + 823 = 1624 ms
- time of   synchronized 4-ElementCache: 134 + 135 = 269 ms
Benchmark for 100000 from 4 charsets:
- time of unsynchronized 2-ElementCache: 1232 + 1284 = 2516 ms
- time of   synchronized 4-ElementCache: 142 + 145 = 287 ms
Benchmark for 100000 from 5 charsets:
- time of unsynchronized 2-ElementCache: 1408 + 1547 = 2955 ms
- time of   synchronized 4-ElementCache: 617 + 683 = 1300 ms
Benchmark for 100000 from 6 charsets:
- time of unsynchronized 2-ElementCache: 1666 + 1671 = 3337 ms
- time of   synchronized 4-ElementCache: 1086 + 995 = 2081 ms


For the sources see attachment.

-Ulf





More information about the core-libs-dev mailing list