caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: "Daniel Bünzli" <daniel.buenzli@epfl.ch>
Cc: Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Profiling a function execution
Date: Thu, 13 Nov 2003 17:53:01 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0311131745160.5009-100000@localhost.localdomain> (raw)
In-Reply-To: <81F621FD-1629-11D8-A1E1-000393DBC266@epfl.ch>

On Thu, 13 Nov 2003, Daniel Bünzli wrote:

> 2) Unix.times seems to have a low resolution, which means that my 
> timings are often 0.0 (unless I execute the function a lot of times). I 
> don't want to use Unix.gettimeofday because this prevents me to make 
> the difference between user and system time. Has anybody bindings to 
> the getrusage function or another idea ?

Clocks on computers have a 10ms quantiziation- i.e., they measure 
everything as multiples of 10 milliseconds.  All measurements are accurate 
only up to about +/- 10 milliseconds.  I.e. if times reports that 
something takes 50 milliseconds, it probably takes more than 40 but less 
than 60 milliseconds.

My recommendation if you want to time something that takes less than 
seconds to do, is to do it lots of times.  You want the amount of time 
between two calls to times to be at least seconds, if not tens of seconds 
or minutes.  You then divide the total amount of time taken by the number 
of times the operation was executed, to get the time per execution.  

Is there a wrapper to the clock function kicking around?

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-11-13 22:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-13 22:34 Daniel Bünzli
2003-11-13 23:53 ` Brian Hurt [this message]
2003-11-14 12:23   ` Ville-Pertti Keinonen
2003-11-14 12:33   ` Richard Jones
2003-11-15 11:11     ` Wolfgang Lux
2003-11-15 12:21       ` David MENTRE
2003-11-15 12:54       ` Richard Jones
2003-11-25 18:05 ` Xavier Leroy
2003-11-25 21:54   ` Daniel Bünzli
2003-11-25 22:38   ` Kim Nguyen
2003-11-26 12:23   ` Ville-Pertti Keinonen

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=Pine.LNX.4.44.0311131745160.5009-100000@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@epfl.ch \
    /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.
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).