Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D432FB5DBD5 for ; Mon, 13 Jun 2011 08:31:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 17827-10 for ; Mon, 13 Jun 2011 11:31:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-vw0-f46.google.com (mail-vw0-f46.google.com [209.85.212.46]) by mail.postgresql.org (Postfix) with ESMTP id 26328B5DBD6 for ; Mon, 13 Jun 2011 08:31:42 -0300 (ADT) Received: by vws1 with SMTP id 1so3517591vws.19 for ; Mon, 13 Jun 2011 04:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=1HM0Pp9sRPdoPexw1Z+N2qlDZa9SBR2CQavl6f7xDJQ=; b=karC/w+z8NCR3TCTTjQWGalFe14VFMW3Coth02vSs9G7t1wdQA34C4Qx/5wivQoLFR aiZ98r+WHzTicTf9rT4r6oEPsOSV6UZxpbJhct1WbPCCt66Yscr8cDYLsLIHAzpj3e4Q xzjm5SazkYzsGcGBOnDemP3nihSQzxXeNHSwU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=Jg+xltPuo7Pr8ccpH0tBpxYB5IzptU1vvi/bw6RTsNWmdgJMFKQ9xNVPpSeme5sfmT 7k5ogB6zUfCgsWpBuckvvDLT6BW3sKBpt7xpST14tL2Lwbz0hA+fjBsSGVPp4h77Dh5K GZQKbB0BaEsUS3LVUAVaw4ll8q4DfGgCu0Nc4= MIME-Version: 1.0 Received: by 10.52.177.1 with SMTP id cm1mr476428vdc.295.1307964701956; Mon, 13 Jun 2011 04:31:41 -0700 (PDT) Received: by 10.52.162.163 with HTTP; Mon, 13 Jun 2011 04:31:41 -0700 (PDT) In-Reply-To: <4DF5B7B3.7010708@postnewspapers.com.au> References: <4DF5B7B3.7010708@postnewspapers.com.au> Date: Mon, 13 Jun 2011 08:31:41 -0300 Message-ID: Subject: Re: Question about speed: Weird Behavior From: Israel Ben Guilherme Fonseca To: pgsql-jdbc@postgresql.org Content-Type: multipart/alternative; boundary=20cf3071c814705ac304a5964303 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.887 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RFC_ABUSE_POST=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201106/27 X-Sequence-Number: 21951 --20cf3071c814705ac304a5964303 Content-Type: text/plain; charset=ISO-8859-1 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 > 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 > --20cf3071c814705ac304a5964303 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable The actual tests are executed many times, I just tried to make a simpler te= st to be easier to understand.

I executed this code some times to ge= t the average of the result.

Other point:

Executing this code= 10 times give different averages of executing the same code in 10 times lo= op. So the system cache is actually linked to the same JVM instance? At eac= h 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 <cra= ig@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 =A0operation: 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<= br> > happens it's a mystery for me. The problem is that my benchmark te= sts
> are influenced with this, cause the order of the tests can influence t= he
> outcome of the total time.

You really need to tweak your benchmarks to reflect more of a real-wo= rld
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

--20cf3071c814705ac304a5964303--