pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedPerformance of loop
4+ messages / 2 participants
[nested] [flat]
* Performance of loop
@ 2005-04-28 03:51 Gnanavel S <s.gnanavel@gmail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Gnanavel S @ 2005-04-28 03:51 UTC (permalink / raw)
To: pgsql-jdbc
Hi,
I would like to thank the postgresql team for providing this wonderful
product.
Coming to the point, in postgresql jdbc driver coding, I saw many
inefficient "for" loops. For eg in V2Query.class file
While parsing the parameterized query, there is a "for" loop as this
for (int i = 0; i < query.length(); ++i)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Performance of loop
@ 2005-04-28 03:56 Gnanavel S <s.gnanavel@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Gnanavel S @ 2005-04-28 03:56 UTC (permalink / raw)
To: pgsql-jdbc
Hi,
First of all, I would like to thank the postgresql team for providing this
wonderful product.
Coming to the point, in postgresql jdbc driver coding, I saw many
inefficient "for" loops. For eg in V2Query.class file
While parsing the parameterized query, there is a "for" loop as this
for (int i = 0; i < query.length(); ++i)
{
char c = query.charAt(i);
....
.....
}
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);
....
.....
}
with regards,
S.Gnanavel
Software Engineer
Satyam Computer Services Ltd
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Performance of loop
@ 2005-04-28 04:22 Oliver Jowett <oliver@opencloud.com>
parent: Gnanavel S <s.gnanavel@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Jowett @ 2005-04-28 04:22 UTC (permalink / raw)
To: Gnanavel S <s.gnanavel@gmail.com>; +Cc: pgsql-jdbc
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Performance of loop
@ 2005-04-28 04:38 Gnanavel S <s.gnanavel@gmail.com>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 0 replies; 4+ messages in thread
From: Gnanavel S @ 2005-04-28 04:38 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: 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.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2005-04-28 04:38 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-04-28 03:51 Performance of loop Gnanavel S <s.gnanavel@gmail.com>
2005-04-28 03:56 Performance of loop Gnanavel S <s.gnanavel@gmail.com>
2005-04-28 04:22 ` Oliver Jowett <oliver@opencloud.com>
2005-04-28 04:38 ` Gnanavel S <s.gnanavel@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox