<?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/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"
  prev="2003/11/ccaf83034bb4211c2c282eaf9cc29131"
  next="2003/11/ec1f30cb4393e6b91eb605d2eff84211"
  prev-in-thread="2003/11/ccaf83034bb4211c2c282eaf9cc29131"
  next-in-thread="2003/11/517bc908d9c80ef3b698d7c821a8317a"
  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>
If you're using a Pentium-class machine, then a nice trick is to wrap
the RDTSC assembly instruction and call that. It returns number of
clock cycles elapsed (a 64 bit number IIRC). Here's some code to get
you started:

#ifdef linux
#include &lt;sys/bitypes.h&gt;
#endif

extern inline u_int64_t
rdtsc (void)
{
  u_int32_t hi, lo;
#ifdef linux
  __asm__ ("rdtsc" : "=d" (hi),  "=a" (lo));
#else
  __asm__ (".byte 0x0f,0x31" : "=d" (hi),  "=a" (lo));
#endif
  return ((u_int64_t) hi) &lt;&lt; 32 | lo;
}

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
"My karma ran over your dogma"

-------------------
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>

