Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Daniel Bünzli" <daniel.buenzli@epfl.ch>
To: Xavier Leroy <xavier.leroy@inria.fr>
Cc: Damien Doligez <damien.doligez@inria.fr>, caml-list@inria.fr
Subject: Re: [Caml-list] Profiling a function execution
Date: Tue, 25 Nov 2003 22:54:42 +0100	[thread overview]
Message-ID: <F99563C4-1F91-11D8-9728-000393DBC266@epfl.ch> (raw)
In-Reply-To: <20031125190553.B1064@pauillac.inria.fr>

Le 25 nov. 03, à 19:05, Xavier Leroy a écrit :

> I haven't looked at other Unix
> kernels, but I suspect that the additional precision made possible by
> the getrusage() syscall is simply not exploited.
I have done tests using the C code appended to this email.

Indeed with the Darwin Kernel 7.0.0 (MacOS X), you don't get extra 
precision with the figures returned by getrusage(). I was mistaken by 
the potential of the data structure described in the man page (there's 
no info about the actual granularity there).

You can remove my wish (id=1937) for getrusage bindings from your 
database.

> your question begs another
> question: why would you need to do distinguish native code from
> bytecode?
I just wanted a quick way to distinguish, on output, my bytecode 
profiles from native ones. This can of course be handled very easily 
with a preprocessor, I was just wondering if I had missed a flag in the 
style of Sys.interactive.

>   We're working hard on removing the last discrepancies
> between the two compilers...
One could argue that since there exists some discrepancies such a flag 
should exist. However I doubt its usefulness in common practice (which 
is why I didn't file a feature wish for that one). Furthermore, if it 
doesn't exist, removing the last discrepancies becomes a must...

Thanks for your answers,

Daniel


--- test.c ---
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include <sys/times.h>
#include <sys/time.h>
#include <sys/resource.h>

#define NUM_OPS ULONG_MAX / 100

void idle (void)
{
   unsigned long i;
   int op;

   for (i = 0; i < NUM_OPS; i++) op = 1+1;
}

void diff_times (void)
{
   struct tms t1, t2;

   times(&t1);
   idle();
   times(&t2);
   printf("times: %fs user %fs sys\n",
	 (double)(t2.tms_utime-t1.tms_utime) / CLK_TCK,
	 (double)(t2.tms_stime-t1.tms_stime) / CLK_TCK);
}

void diff_getrusage(void)
{
   struct rusage t1, t2;

   getrusage(RUSAGE_SELF, &t1);
   idle();
   getrusage(RUSAGE_SELF, &t2);
   printf("getrusage: %fs user %fs sys\n",
	 (double)t2.ru_utime.tv_sec + (double)t2.ru_utime.tv_usec / 1e6 -
	 ((double)t1.ru_utime.tv_sec + (double)t1.ru_utime.tv_usec / 1e6),
	 (double)t2.ru_stime.tv_sec + (double)t2.ru_stime.tv_usec / 1e6 -
	 ((double)t1.ru_stime.tv_sec + (double)t1.ru_stime.tv_usec / 1e6));
	
}

int main(int argc, char **argv)
{
   diff_times();
   diff_getrusage();
   return 0;
}
-------------------
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-25 21:54 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
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 [this message]
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=F99563C4-1F91-11D8-9728-000393DBC266@epfl.ch \
    --to=daniel.buenzli@epfl.ch \
    --cc=caml-list@inria.fr \
    --cc=damien.doligez@inria.fr \
    --cc=xavier.leroy@inria.fr \
    /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