Re: Performance of loop - Mailing list pgsql-jdbc

From Gnanavel S
Subject Re: Performance of loop
Date
Msg-id eec3b03c050427213841e5062@mail.gmail.com
Whole thread Raw
In response to Re: Performance of loop  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
No. I havn't done any benchmark, but lot of such inefficient loops may hit the performance.

On 4/28/05, Oliver Jowett < oliver@opencloud.com> wrote:
Gnanavel S wrote:

> In the above coding, say if the length of the query is 1000 characters
> then the query.length() is evaluated 1000 times there by reducing the
> performance.
>  I think the loop can be rewritten as
>
> for (int i = 0,c=query.length(); i < c; ++i)
> {
> char c = query.charAt(i);
>
> ....
> .....
> }

Have you benchmarked this? I doubt it's really a hotspot given that the
JIT is likely to inline length(). Premature optimization and all that..

-O



--
with regards,
S.Gnanavel
Satyam Computer Services Ltd.

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: Performance of loop
Next
From: Kris Jurka
Date:
Subject: Re: _pg_keyposition is gone in HEAD