* high resolution timer?
@ 1999-07-21 4:00 Alex Rhomberg
1999-07-21 4:00 ` Robert Harley
0 siblings, 1 reply; 2+ messages in thread
From: Alex Rhomberg @ 1999-07-21 4:00 UTC (permalink / raw)
Hello
I'm looking for a way to profile my programs in detail. for this, I need
a register with at least microsecond resolution. A register that just
counts the cycles would be fine.
Does anybody know if this exists on a Miata?
- Alex
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: high resolution timer?
1999-07-21 4:00 high resolution timer? Alex Rhomberg
@ 1999-07-21 4:00 ` Robert Harley
0 siblings, 0 replies; 2+ messages in thread
From: Robert Harley @ 1999-07-21 4:00 UTC (permalink / raw)
Alex Rhomberg <rhomberg@ife.ee.ethz.ch> writes:
> I'm looking for a way to profile my programs in detail. for this, I need
> a register with at least microsecond resolution. A register that just
> counts the cycles would be fine.
There is a cycle-counter that you can read with the 'rpcc' instruction.
The result is a 64-bit number. The low 32 bits count the actual
cycles executed. The high 32 bits are an offset that is supposed to
allow you to determine the cycles used by the current process.
Unfortunately the offset seems to be bogus. Presumably the PAL code
or kernel (or whatever is supposed to set it) doesn't do it right.
To measure very short times, you can use the real cycle count and
filter out the garbage from context switches: for instance measure
five times and take the median.
For longer times, use getrusage() and friends.
NB: Beware that 32-bit cycle counters wrap around in a few seconds!
Bye,
Rob.
#if defined(__GNUC__) && defined(__alpha)
/* Cool! */
typedef unsigned u32;
typedef unsigned long u64;
/* Return the 64-bit process cycle counter. */
static inline u64 rpcc(void) {
u64 cyc;
asm volatile("rpcc %0" : "=r"(cyc) :: "memory");
return cyc;
} /* end rpcc */
/* Return the real cycle count. */
static inline u32 realcc(void) {
u64 cyc;
asm volatile("rpcc %0" : "=r"(cyc) :: "memory");
return (u32)cyc;
} /* end realcc */
/* Return the virtual cycle count, using the process offset. */
static inline u32 virtcc(void) {
u64 cyc;
asm volatile("rpcc %0" : "=r"(cyc) :: "memory");
return (u32)(cyc+(cyc>>32));
} /* end virtcc */
#else
#error Too bad, dude.
#end
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-07-21 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-07-21 4:00 high resolution timer? Alex Rhomberg
1999-07-21 4:00 ` Robert Harley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox