Exemplo n.º 1
0
int
main(int argc, char *argv[])
{
    int i;
    int j;
#if (EVPROF)
    PROFDECLCLK(clk);
    PROFDECLTICK(tck);
#endif

    for ( ; ; ) {
        nread = 0;
        nwrite = 0;
        nrcycle = 0;
        nwcycle = 0;
#if (EVPROF) && 0
        profstartclk(clk);
#endif
        for (i = 0 ; i < 256 ; i++) {
#if (!EVPROF)
            fprintf(stderr, "QUEUE: %d\n", i);
#endif
#if (EVPROF)
            profstarttick(tck);
#endif
            evqkbdchar(&evkbdqueue, i);
#if (EVPROF)
            profstoptick(tck);
            nwrite++;
            nwcycle += proftickdiff(tck);
#endif
        }
        for (i = 0 ; i < 256 ; i++) {
#if (EVPROF)
            profstarttick(tck);
#endif
            j = evdeqkbdchar(&evkbdqueue);
#if (EVPROF)
            profstoptick(tck);
            nread++;
            nrcycle += proftickdiff(tck);
#endif
            if (j != i) {
                fprintf(stderr, "FAILURE: %d (%d)\n", i, j);

                exit(1);
            }
        }
#if (EVPROF) && 0
        profstopclk(clk);
        fprintf(stderr, "%ld\n", profclkdiff(clk));
#endif
#if (EVPROF)
        fprintf(stderr, "%ld cycles per read\n", nrcycle / nread);
        fprintf(stderr, "%ld cycles per write\n", nwcycle / nwrite);
#endif
    }

    exit(0);
}
Exemplo n.º 2
0
void
profmul(void)
{
    long double ld1, ld2;
    double      d1, d2;
    float       f1, f2;
    PROFDECLCLK(clock);
    PROFDECLTICK(tick);

    sleep(1);
    d2 = 1.0;
    profstartclk(clock);
    profstarttick(tick);
    for (d1 = 0.0 ; d1 < (double)PROF_ITERATIONS ; d1 += 1.0) {
        d2 *= d1;
    }
    profstoptick(tick);
    profstopclk(clock);
    fprintf(stderr, "mul\t%Lf\t%Lf\n",
            (long double)proftickdiff(tick) / (long double)PROF_ITERATIONS,
            (long double)profclkdiff(clock) / (long double)PROF_ITERATIONS);

    sleep(1);
    f2 = 1.0;
    profstartclk(clock);
    profstarttick(tick);
    for (f1 = 0.0 ; f1 < (float)PROF_ITERATIONS ; f1 += 1.0) {
        f2 *= f1;
    }
    profstoptick(tick);
    profstopclk(clock);
    fprintf(stderr, "mulf\t%Lf\t%Lf\n",
            (long double)proftickdiff(tick) / (long double)PROF_ITERATIONS,
            (long double)profclkdiff(clock) / (long double)PROF_ITERATIONS);

    sleep(1);
    ld2 = 1.0;
    profstartclk(clock);
    profstarttick(tick);
    for (ld1 = 0.0 ; ld1 < (long double)PROF_ITERATIONS ; ld1 += 1.0) {
        ld2 *= ld1;
    }
    profstoptick(tick);
    profstopclk(clock);
    fprintf(stderr, "mull\t%Lf\t%Lf\n",
            (long double)proftickdiff(tick) / (long double)PROF_ITERATIONS,
            (long double)profclkdiff(clock) / (long double)PROF_ITERATIONS);

    return;
}