mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jens Gustedt <jens.gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: Re: sign (in)consistency between architectures
Date: Thu, 02 May 2013 10:12:39 +0200	[thread overview]
Message-ID: <1367482359.28119.118.camel@eris.loria.fr> (raw)
In-Reply-To: <20130502024753.GO20323@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 1810 bytes --]

Am Mittwoch, den 01.05.2013, 22:47 -0400 schrieb Rich Felker:
> In any case, I think all of these issues are good arguments that
> nobodu should ever use clock_t or the clock() function...

Hm, AFAIR clock() is the only available function in C alone (including
C11) that gives access to something like the "processor time". C11 a
bit more of time handling to have access to something like a real time
clock, but for processor time clock() is the only one. (MS got that
wrong, but this is their problem.)

So I think it still makes sense to use it for "short" measures, not
for the whole run of a program. The standard suggests, I think, that
you'd take a point of measure before and after the interval that
interests you. For such a strategy to work you'd either have to know
that no overflow can reasonably occur (by having a wide type) or that
it may do no harm (by using an unsigned type).

I would prefer to have both worlds by using uint64_t (or directly the
underlying base type) uniformly. There is no reason to have it signed:

 - this is "processor time" and not wallclock time, so it should be
   monotonic, and not be affected by setting the system time
 - an application should always subtract the first value of a measure
   from the second
 - an application should never expect to be able to measure intervals
   that are longer than a few hours, and it can deduce the maximum
   time it has for a measure with CLOCKS_PER_SEC

Jens


-- 
:: INRIA Nancy Grand Est :: http://www.loria.fr/~gustedt/   ::
:: AlGorille ::::::::::::::: office Nancy : +33 383593090   ::
:: ICube :::::::::::::: office Strasbourg : +33 368854536   ::
:: ::::::::::::::::::::::::::: gsm France : +33 651400183   ::
:: :::::::::::::::::::: gsm international : +49 15737185122 ::




[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2013-05-02  8:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-01 17:05 Z. Gilboa
2013-05-01 18:00 ` Szabolcs Nagy
2013-05-01 20:00   ` Rich Felker
2013-05-01 22:41     ` Rich Felker
2013-05-02  1:39       ` Z. Gilboa
2013-05-02  2:47         ` Rich Felker
2013-05-02  8:12           ` Jens Gustedt [this message]
2013-05-02 10:13             ` Szabolcs Nagy
2013-05-02 12:12               ` Jens Gustedt
2013-05-02 13:08                 ` Szabolcs Nagy

Reply instructions:

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

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

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1367482359.28119.118.camel@eris.loria.fr \
    --to=jens.gustedt@inria.fr \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).