pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John A Meinel <john@arbash-meinel.com>
To: Dave Held <dave.held@arrayservicesgrp.com>
Cc: pgsql-performance@postgresql.org
Cc: pgsql-hackers-win32@postgresql.org
Subject: Re: [PERFORM] Help with tuning this query (with
Date: Mon, 07 Mar 2005 16:48:10 -0600
Message-ID: <422CDA2A.1000105@arbash-meinel.com> (raw)
In-Reply-To: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846B@asg002.asg.local>
References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846B@asg002.asg.local>

Dave Held wrote:

>There is always clock().  It's mandated by ANSI C, but my docs say
>that POSIX requires CLOCKS_PER_SEC == 1000000 regardless of actual
>timer resolution, which seems a little brain-dead to me.
>
>__
>David B. Held
>  
>

My experience with clock() on win32 is that CLOCKS_PER_SEC was 1000, and 
it had a resolution of 55clocks / s. When I just did this:

int main(int argc, char **argv)
{
    int start = clock();
    int now = start;
    cout << "Clock: " << CLOCKS_PER_SEC << endl;
    for(int i = 0; i < 10; ++i) {
        while(now == clock()) {
            // Do nothing
        }
        now = clock();
        cout << now-start << "\t" << (now - start) / (double) 
CLOCKS_PER_SEC << endl;
    }
}

I got:
Clock: 1000
16      0.016
31      0.031
47      0.047
62      0.062
78      0.078
93      0.093
109     0.109
125     0.125
141     0.141
156     0.156

Which is about 1/0.016 = 62.5 clocks per second.
I'm pretty sure this is slightly worse than what we want. :)
It might be better on other platforms, but on win32 clock() is most 
definitely *not* what you want.
John
=:->

Attachments:

  signature.asc (application/pgp-signature, 252B) download

view thread (16+ messages)  latest in thread

Message-ID: <422CDA2A.1000105@arbash-meinel.com>
Permalink:  ../422CDA2A.1000105@arbash-meinel.com/
Also on:    postgresql.org/message-id/422CDA2A.1000105@arbash-meinel.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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: john@arbash-meinel.com, dave.held@arrayservicesgrp.com, pgsql-hackers-win32@postgresql.org
  Subject: Re: [PERFORM] Help with tuning this query (with
  In-Reply-To: <422CDA2A.1000105@arbash-meinel.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