harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Regis <xu.re...@gmail.com>
Subject Re: [jira] Commented: (HARMONY-6045) [classlib] [luni] Optimize java.lang.String.toUpperCase(), String.toLowerCase() and String sharing for more performance gains
Date Mon, 20 Apr 2009 06:42:41 GMT
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 <xu.regis@gmail.com> 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.

Mime
View raw message