Browse thread
[Caml-list] Profiling a function execution
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Richard Jones <rich@a...> |
| Subject: | Re: [Caml-list] Profiling a function execution |
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