From: Israel Ben Guilherme Fonseca <israel.bgf@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Question about speed: Weird Behavior
Date: Mon, 13 Jun 2011 08:31:41 -0300
Message-ID: <BANLkTimPigO8As72fj7MR59JU9GgzJSuyw@mail.gmail.com> (raw)
In-Reply-To: <4DF5B7B3.7010708@postnewspapers.com.au>
References: <BANLkTimTaoOnVMcuUhnhE5VodRVDSTyH0w@mail.gmail.com>
<4DF5B7B3.7010708@postnewspapers.com.au>
The actual tests are executed many times, I just tried to make a simpler
test to be easier to understand.
I executed this code some times to get the average of the result.
Other point:
Executing this code 10 times give different averages of executing the same
code in 10 times loop. So the system cache is actually linked to the same
JVM instance? At each separated invocation the values keep somewhat
constant, differently from one execution with a loop.
I'll try the "select *" approach in the terminal later.
2011/6/13 Craig Ringer <craig@postnewspapers.com.au>
> On 13/06/11 11:14, Israel Ben Guilherme Fonseca wrote:
>
> > At every stop, I print the milliseconds occurred between the begin and
> > the end of the operation. The results were basically
> >
> > 1st operation: 0.05 miliseconds
> > 2nd operation: 0.1 miliseconds
>
> I suspect you're right on the border of the precision the timers you are
> using can offer you. It's hard to be sure as you didn't mention you
> platform, CPU, or JDK version.
>
> Try using System.nanoTime() for your timing, and/or (much better) do
> many iterations rather than just one to try to smooth out error and jitter.
>
>
> http://download.oracle.com/javase/1,5.0/docs/api/java/lang/System.html#nanoTime()
>
> > Anyway, that speed increases is definitely a good thing, but why this
> > happens it's a mystery for me. The problem is that my benchmark tests
> > are influenced with this, cause the order of the tests can influence the
> > outcome of the total time.
>
> You really need to tweak your benchmarks to reflect more of a real-world
> workload. Timing tiny statements stand-alone will not give you data with
> any relationship to what will happen under real load with many such
> operations happening concurrently or thousands of them being executed in
> rapid sequence.
>
> --
> Craig Ringer
>
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: israel.bgf@gmail.com
Subject: Re: Question about speed: Weird Behavior
In-Reply-To: <BANLkTimPigO8As72fj7MR59JU9GgzJSuyw@mail.gmail.com>
References: <BANLkTimTaoOnVMcuUhnhE5VodRVDSTyH0w@mail.gmail.com> <4DF5B7B3.7010708@postnewspapers.com.au> <BANLkTimPigO8As72fj7MR59JU9GgzJSuyw@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