pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gnanavel S <s.gnanavel@gmail.com>
To: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Performance of loop
Date: Thu, 28 Apr 2005 10:08:59 +0530
Message-ID: <eec3b03c050427213841e5062@mail.gmail.com> (raw)
In-Reply-To: <42706503.7080800@opencloud.com>
References: <eec3b03c050427205669495af0@mail.gmail.com>
	<42706503.7080800@opencloud.com>

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.

view thread (4+ messages)

Message-ID: <eec3b03c050427213841e5062@mail.gmail.com>
Permalink:  ../eec3b03c050427213841e5062@mail.gmail.com/
Also on:    postgresql.org/message-id/eec3b03c050427213841e5062@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: s.gnanavel@gmail.com, oliver@opencloud.com
  Subject: Re: Performance of loop
  In-Reply-To: <eec3b03c050427213841e5062@mail.gmail.com>
  References: <eec3b03c050427205669495af0@mail.gmail.com> <42706503.7080800@opencloud.com> <eec3b03c050427213841e5062@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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