db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sunitha Kambhampati <ksunitha...@gmail.com>
Subject Re: [jira] Commented: (DERBY-525) getAsciiStreamshould replace non-ASCII characters with 0x3f, '?' to match embedded
Date Thu, 29 Sep 2005 23:07:47 GMT
TomohitoNakayama wrote:

> Hello.
>
> I have one question ...
>
>> I looked at the patch briefly, and had one minor comment.  In 
>> convertToAsciiByteArray, it might be better performance wise, if we 
>> calculate the original.length only once and use it in the for loop.
>
>
> Can it be improvement of performance so much ?
>
> Length of String object cannot be changed and there would be very less 
> performance improvement .
> //Improvement would be just saving time of calling method .
>
I think it is cheaper to store the int value, rather than calling the 
method N times.  I did a simple test just to get some numbers with using 
the length() versus calculating once.  Note- this test doesnt make much 
sense otherwise..

string length = 810023
test  calls method  length() each time   = 140 ms
test precomputes length and uses the stored length = 90ms.

ex.
        for(int j= 0; j < len; j++)
        {
            if (sb1.charAt(j) == 'a')
            {
               c = sb1.charAt(j);
            }
        }

versus,  computing the length() each time.
---------------

Java^TM Performance Tuning and Java Optimization Tips : 
ftp://ftp.glenmccl.com/pub/free/jperf.pdf  : check out section 4.5.where 
the author mentions some timing details, although the example code is 
not right. :(

Hope this helps,
Sunitha.

> Rather, I feel question for adding (local) variable , because I don't 
> want to increase number of variable even if it is local ....
>
> Best regards.
>
> /*
>
>         Tomohito Nakayama
>         tomonaka@basil.ocn.ne.jp
>         tomohito@rose.zero.ad.jp
>         tmnk@apache.org
>
>         Naka
>         http://www5.ocn.ne.jp/~tomohito/TopPage.html
>
> */
> ----- Original Message ----- From: "Sunitha Kambhampati (JIRA)" 
> <derby-dev@db.apache.org>
> To: <derby-dev@db.apache.org>
> Sent: Friday, September 30, 2005 2:13 AM
> Subject: [jira] Commented: (DERBY-525) getAsciiStreamshould replace 
> non-ASCII characters with 0x3f, '?' to match embedded
>
>
>>    [ 
>> http://issues.apache.org/jira/browse/DERBY-525?page=comments#action_12330828 
>> ]
>>
>> Sunitha Kambhampati commented on DERBY-525:
>> -------------------------------------------
>>
>> It would be great if you could add a testcase for this.
>>
>> I looked at the patch briefly, and had one minor comment.  In 
>> convertToAsciiByteArray, it might be better performance wise, if we 
>> calculate the original.length only once and use it in the for loop.
>>
>>


Mime
View raw message