The content of the previous path on String.toUpperCase focuses on some special locales. I agree with Regis's new patch. Thanks, Regis!
On Mon, Apr 27, 2009 at 5:10 PM, Regis <[email protected]> wrote: > Hi, > > I uploaded a new micro benchmark StringConvertCase.v2.java to HARMONY-6045, > which also compare String.compareToIgnoreCase. > > Following are results on Linux: > > * Without any patches: > String.toUpperCase > count per cycle: 1000000 > 2681 2646 2656 2672 2666 > String.toLowerCase > count per cycle: 1000000 > 1888 1899 1890 1855 1860 > String.compareToIgnoreCase > count per cycle: 1000000 > 4177 3959 3958 3995 3998 > > * Apply patch HARMONY-6045v2.diff: > String.toUpperCase > count per cycle: 1000000 > 5736 5699 5690 5647 5714 > String.toLowerCase > count per cycle: 1000000 > 1145 1146 1194 1183 1146 > String.compareToIgnoreCase > count per cycle: 1000000 > 3397 2888 2887 2888 2890 > > It seems HARMONY-6045v2.diff cause performance degradation on > String.toUpperCase. So I reverted String.toUpperCase, changed > Character.toUpperCase to toUpperCase instead, and some other minor fixes > (patch HARMONY-6045.v3.diff), I got: > > * Apply patch HARMONY-6045.v3.diff: > String.toUpperCase > count per cycle: 1000000 > 2059 2010 2052 2016 2048 > String.toLowerCase > count per cycle: 1000000 > 1145 1185 1137 1170 1136 > String.compareToIgnoreCase > count per cycle: 1000000 > 1785 1492 1532 1501 1542 > > String.toUpperCase, String.toLowerCase and String.compareToIgnoreCase all > got improvement, so I proposal to apply HARMONY-6045.v3.diff first. It seems > HARMONY-6045v2.diff contains code to deal with specific locale "az", I hope > some experts in this area may give some advices. > > > Regis wrote: > >> I found at String:619, it should be >> return codePoint - ('a' - 'A'); >> >> and at String:595, it should be >> return (char) (ch + ('a' - 'A')); >> >> Is it right? And for private char compareValue, could we return directly >> if it's ASCII lower case, like: >> private char compareValue(char ch) { >> if (ch < 128) { >> if ('A' <= ch && ch <= 'Z') { >> return (char) (ch + ('a' - 'A')); >> } >> return ch; >> } >> return Character.toLowerCase(Character.toUpperCase(ch)); >> } >> >> Regis wrote: >> >>> Kevin Zhou wrote: >>> >>>> It looks good! :) >>>> >>> >>> Not so good, it cause test failures. seems most of them are failed in >>> compareToIgnoreCase and toUpperCase. Would you please take a look at it? >>> >>> >>>> On Mon, Apr 20, 2009 at 1:53 PM, Regis <[email protected]> wrote: >>>> >>>> Regis wrote: >>>>> >>>>> Kevin Zhou wrote: >>>>>> >>>>>> Previously, it is proved by using benchmarks like Specjbb. >>>>>>> Since it's been a long time I don't really remember the accurate >>>>>>> statistics >>>>>>> of how much improvements it brings. >>>>>>> >>>>>>> All right, I will try to write some micro benchmarks :) >>>>>> >>>>>> I have attached a very simple micro benchmark for converting case of >>>>> ASCII >>>>> character. The patch seems great: >>>>> >>>>> * before the patch HARMONY-6045v2.diff: >>>>> String.toUpperCase >>>>> count per cycle: 1000000 >>>>> 2779 2727 2706 2768 2745 >>>>> String.toLowerCase >>>>> count per cycle: 1000000 >>>>> 1929 1934 1940 1963 1911 >>>>> >>>>> * after the patch: >>>>> String.toUpperCase >>>>> count per cycle: 1000000 >>>>> 1380 1350 1355 1359 1423 >>>>> String.toLowerCase >>>>> count per cycle: 1000000 >>>>> 1182 1189 1189 1177 1171 >>>>> >>>>> * RI 1.5: >>>>> String.toUpperCase >>>>> count per cycle: 1000000 >>>>> 3123 3181 3132 3117 3156 >>>>> String.toLowerCase >>>>> count per cycle: 1000000 >>>>> 3375 3328 3394 3336 3390 >>>>> >>>>> for String.toUpperCase, average from 2745 to 1373.4, improve almost >>>>> 100% >>>>> for String.toLowerCase, average from 1935.4 to 1181.6, improve 64% >>>>> >>>>> But I noticed there are tests failed after patch: >>>>> org.apache.harmony.luni.tests.java.lang.Character_UnicodeBlockTest >>>>> org.apache.harmony.luni.tests.java.lang.String2Test >>>>> >>>>> org.apache.harmony.luni.tests.internal.net.www.protocol.file.FileURLConnectionTest >>>>> >>>>> org.apache.harmony.luni.tests.java.util.Arrays2Test >>>>> org.apache.harmony.luni.tests.java.net.URITest >>>>> org.apache.harmony.luni.tests.java.net.URLConnectionTest >>>>> >>>>> >>>>> -- >>>>> Best Regards, >>>>> Regis. >>>>> >>>>> >>>> >>> >>> >> >> > > -- > Best Regards, > Regis. >
