2 #include "../port/lib.h"
11 Cyccntres = 2, /* counter advances at ½ clock rate */
12 Basetickfreq = 150*Mhz / Cyccntres, /* sgi/indy */
26 --i; --i; --i; --i; --i; --i; --i; --i; --i; --i;
27 --i; --i; --i; --i; --i; --i; --i; --i; --i; --i;
28 --i; --i; --i; --i; --i; --i; --i; --i; --i; --i;
29 --i; --i; --i; --i; --i; --i; --i; --i; --i; --i;
30 --i; --i; --i; --i; --i; --i; --i; --i; --i; --i;
31 --i; --i; --i; --i; --i; --i; --i; --i; --i; --i;
32 --i; --i; --i; --i; --i; --i; --i; --i; --i; --i;
33 --i; --i; --i; --i; --i; --i; --i; --i; --i; --i;
34 --i; --i; --i; --i; --i; --i; --i; --i; --i; --i;
35 --i; --i; --i; --i; --i;
36 /* omit 3 (--i) to account for conditional branch, nop & jump */
37 i -= 1+3; /* --i plus 3 omitted (--i) instructions */
39 return perfticks() - st;
42 /* estimate instructions/s. */
44 guessmips(long (*loop)(void), char *)
57 * Instrs instructions took cyc cycles @ Basetickfreq Hz.
60 return (((vlong)Basetickfreq * Instrs) / cyc + Mhz/2) / Mhz;
71 mips = guessmips(issue1loop, "single");
74 * m->delayloop should be the number of delay loop iterations
75 * needed to consume 1 ms, assuming 2 instr'ns in the delay loop.
77 m->delayloop = mips*Mhz / (1000 * 2);
84 m->maxperiod = Basetickfreq / HZ;
85 m->minperiod = Basetickfreq / (100*HZ);
86 m->lastcount = rdcount();
87 wrcompare(m->lastcount+m->maxperiod);
95 wrcompare(rdcount()+m->maxperiod); /* side-effect: dismiss intr */
104 while(µs() - now < n);
117 return fastticks2us(fastticks(nil));
121 fastticks(uvlong *hz)
129 /* avoid reentry on interrupt or trap, to prevent recursion */
132 delta = count - m->lastcount;
133 m->lastcount = count;
134 m->fastticks += delta;
151 period = next - fastticks(nil);
152 if(period < m->minperiod)
153 period = m->minperiod;
154 else if(period > m->maxperiod - m->minperiod)
155 period = m->maxperiod;
156 wrcompare(rdcount()+period);