caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
Cc: Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Profiling a function execution
Date: Fri, 14 Nov 2003 12:33:58 +0000	[thread overview]
Message-ID: <20031114123358.GA24353@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0311131745160.5009-100000@localhost.localdomain>

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 <sys/bitypes.h>
#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) << 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


  parent reply	other threads:[~2003-11-14 12:34 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 [this message]
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=20031114123358.GA24353@redhat.com \
    --to=rich@annexia.org \
    --cc=caml-list@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;
as well as URLs for NNTP newsgroup(s).