<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/3926d9185cb59338ebbe489e8e1ae367"
  from="Daniel_Bünzli &lt;daniel.buenzli@e...&gt;"
  author="Daniel_Bünzli"
  date="2003-11-25T21:54:42"
  subject="Re: [Caml-list] Profiling a function execution"
  prev="2003/11/6f41f08fba60b932f48b1673055f188d"
  next="2003/11/abed68f2aff7b7909b4122601db58bdd"
  prev-in-thread="2003/11/6f41f08fba60b932f48b1673055f188d"
  next-in-thread="2003/11/099ebe67b9b5a5241762a30b9a733ffb"
  prev-thread="2003/11/3f569e7c0ae6343b3f1d7e892dcba645"
  next-thread="2003/11/659715962834b450cc1e0aeddeb9dc7e"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Profiling a function execution">
<msg 
  url="2003/11/34f26b24813463c04244b74a889dc2a3"
  from="Daniel_Bünzli &lt;daniel.buenzli@e...&gt;"
  author="Daniel_Bünzli"
  date="2003-11-13T22:34:14"
  subject="[Caml-list] Profiling a function execution">
<msg 
  url="2003/11/9f922a27f598ae82ac0f62db2c953605"
  from="Brian Hurt &lt;bhurt@s...&gt;"
  author="Brian Hurt"
  date="2003-11-13T22:53:58"
  subject="Re: [Caml-list] Profiling a function execution">
<msg 
  url="2003/11/ccaf83034bb4211c2c282eaf9cc29131"
  from="Ville-Pertti Keinonen &lt;will@e...&gt;"
  author="Ville-Pertti Keinonen"
  date="2003-11-14T12:23:53"
  subject="Re: [Caml-list] Profiling a function execution">
</msg>
<msg 
  url="2003/11/188916524dd342aefc88d89218040ae7"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-11-14T12:34:04"
  subject="Re: [Caml-list] Profiling a function execution">
<msg 
  url="2003/11/517bc908d9c80ef3b698d7c821a8317a"
  from="Wolfgang Lux &lt;wlux@u...&gt;"
  author="Wolfgang Lux"
  date="2003-11-15T11:11:19"
  subject="Re: [Caml-list] Profiling a function execution">
<msg 
  url="2003/11/f561faa2124a980042c1f6b2ea4c38a4"
  from="David MENTRE &lt;dmentre@l...&gt;"
  author="David MENTRE"
  date="2003-11-15T12:21:34"
  subject="Re: [Caml-list] Profiling a function execution">
</msg>
<msg 
  url="2003/11/4ad33fa3b94199e611c2eaf3954d0041"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-11-15T12:54:11"
  subject="Re: [Caml-list] Profiling a function execution">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/11/6f41f08fba60b932f48b1673055f188d"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2003-11-25T18:05:56"
  subject="Re: [Caml-list] Profiling a function execution">
<msg 
  url="2003/11/3926d9185cb59338ebbe489e8e1ae367"
  from="Daniel_Bünzli &lt;daniel.buenzli@e...&gt;"
  author="Daniel_Bünzli"
  date="2003-11-25T21:54:42"
  subject="Re: [Caml-list] Profiling a function execution">
</msg>
<msg 
  url="2003/11/099ebe67b9b5a5241762a30b9a733ffb"
  from="Kim Nguyen &lt;nguyen@b...&gt;"
  author="Kim Nguyen"
  date="2003-11-25T22:36:27"
  subject="Re: [Caml-list] Profiling a function execution">
</msg>
<msg 
  url="2003/11/615473df5cbf28e2eb2ecd0c2052564a"
  from="Ville-Pertti Keinonen &lt;will@e...&gt;"
  author="Ville-Pertti Keinonen"
  date="2003-11-26T12:23:29"
  subject="Re: [Caml-list] Profiling a function execution">
</msg>
</msg>
</msg>
</thread>

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

&gt; I haven't looked at other Unix
&gt; kernels, but I suspect that the additional precision made possible by
&gt; 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.

&gt; your question begs another
&gt; question: why would you need to do distinguish native code from
&gt; 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.

&gt;   We're working hard on removing the last discrepancies
&gt; 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 &lt;limits.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;
#include &lt;time.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;sys/times.h&gt;
#include &lt;sys/time.h&gt;
#include &lt;sys/resource.h&gt;

#define NUM_OPS ULONG_MAX / 100

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

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

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

   times(&amp;t1);
   idle();
   times(&amp;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, &amp;t1);
   idle();
   getrusage(RUSAGE_SELF, &amp;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

</contents>

</message>

