From: Godmar Back (gback@cs.utah.edu)
Date: Fri Dec 04 1998 - 15:47:22 EST
>
> This is a MIME multipart message. If you are reading
> this, you shouldn't.
>
> --==-=-=
>
> On Dec 4, 1998, Godmar Back <gback@cs.utah.edu> wrote:
>
> > Again, standard benchmark is compiling the run-time libraries,
> > I'm looking at the user time given by time to get a rough estimate.
>
> If you mean to do real performance checking, you may give the attached
> program a try.
>
Which reminds me: instead of using currentTimeMillis,
how about this.
-------
package sys;
/**
* Give Java programs access to the cycle counter on Pentium PCs.
*/
public class CycleCounter
{
/**
* read the current cycle counter
*/
public static native long read();
}
-------
/*
* Read the 64-bit timestamp counter (TSC) register.
* Works only on Pentium and higher processors,
* and in user mode only if the TSD bit in CR4 is not set.
*/
#if HAVE_RDTSC
#define get_tsc() \
({ \
unsigned long low, high; \
asm volatile("rdtsc" : "=d" (high), "=a" (low)); \
((unsigned long long)high << 32) | low; \
})
#else
#define get_tsc() \
({ \
unsigned long low, high; \
asm volatile( \
".byte 0x0f; .byte 0x31" \
: "=d" (high), "=a" (low)); \
((unsigned long long)high << 32) | low; \
})
#endif
#include <jni.h>
jlong
Java_sys_CycleCounter_read(JNIEnv *env, jclass counterclass)
{
return (jlong)get_tsc();
}
---------------------------------------------------------------------
Should we start a place in the kaffe repository to share little
goodies like that?
- Godmar
This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:05 EDT