Support for gethrtime() on other OS's than Solaris 2.x
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=101
Reported by @grubba
From: Daniel Podlejski <underley@underley.eu.org>
To: pike@idonex.se
Date: Thu, 24 Aug 2000 09:45:31 +0200
Subject: Re: profiling with gethrtime
Mirar wrote:
[...]
: Note that gettimeofday adds a lot of overhead, which might be
: misleading in the result.
I found something like this:
#define RTSC(x) __asm__ __volatile__ ( "rdtsc" \
:"=a" (((unsigned long*)&x)[0]),
\
"=d" (((unsigned long*)&x)[1]))
long long gethrtime()
{
long long res;
RTSC(res);
return res/5000;
}
but this is x86 (pentium, PII, PIII, K6) specyfic.
There is "patch" to enable profiling times into pike:
--- src/interpret.c.orig Thu Aug 24 09:42:39 2000 +++ src/interpret.c Thu Aug 24 09:43:40 2000 @@ -51,6 +51,22 @@ #endif #endif
+#ifndef HAVE_GETHRTIME
+#define HAVE_GETHRTIME
+
+#define RTSC(x) __asm__ __volatile__ ( "rdtsc" \
+ :"=a" (((unsigned long*)&x)[0]),
\
+ "=d" (((unsigned long*)&x)[1]))
+
+long long gethrtime()
+{
+ long long res;
+ RTSC(res);
+ return res/5000;
+}
+
+#endif
+
/*
* Define the default evaluator stack size, used for just about
everything.
*/
And get_profiling_info works better.
-- Daniel Podlejski underley@underley.eu.org ... Political speeshes They are lying in the mud Nothing else matters But money and blood ...