Beispiel #1
0
int main(int argc, char *argv[]) {
    int n = 1;
    double cvals[NVALS];
    int ccnts[NVALS];
    int nval = 0;
    if (argc > 1) {
	n = atoi(argv[1]);
    }
    int i, j;
    for (i = 0; i < n; i++) {
	double c = mhz(1) / 1000.0;
	int found = 0;
	for (j = 0; !found && j < nval; j++) {
	    if (found = (c == cvals[j]))
		ccnts[j]++;
	}
	if (!found) {
	    cvals[nval] = c;
	    ccnts[nval++] = 1;
	}
	int stime = random() & 0x7;
	printf("Sleeping for %d seconds\n", stime);
	sleep(stime);
    }
    if (nval == 1) {
	printf("Stable clock rate = %.2f\n", cvals[0]);
    } else {
	printf("Multiple clock rates measured:");
	for (j = 0; j < nval; j++) {
	    printf(" %.2f (%d times)", cvals[j], ccnts[j]);
	}
	printf("\n");
    }
    return 0;
}
Beispiel #2
0
/* $begin mountainmain */
int main()
{
    int size;        /* Working set size (in bytes) */
    int stride;      /* Stride (in array elements) */
    double Mhz;      /* Clock frequency */

    init_data(data, MAXELEMS); /* Initialize each element in data to 1 */
    Mhz = mhz(0, 4);             /* Estimate the clock frequency */
/* $end mountainmain */
    /* Not shown in the text */
    printf("Clock frequency is approx. %.1f MHz\n", Mhz);
    printf("Memory mountain (MB/sec)\n");

    printf("\t");
    for (stride = 1; stride <= MAXSTRIDE; stride++)
	printf("s%d\t", stride);
    printf("\n");

 /* $begin mountainmain */
    for (size = MAXBYTES; size >= MINBYTES; size >>= 1) {
/* $end mountainmain */
	/* Not shown in the text */
	if (size > (1 << 20))
	    printf("%dm\t", size / (1 << 20));
	else
	    printf("%dk\t", size / 1024);

/* $begin mountainmain */
	for (stride = 1; stride <= MAXSTRIDE; stride++) {
	    printf("%.1f\t", run(size, stride, Mhz));
	}
	printf("\n");
    }
    exit(0);
}
Beispiel #3
0
void start_counter()
{
    if (cpu_ghz == 0.0)
	mhz(gverbose);
    if (clock_gettime(CLKT, &last_time) != 0) {
	fprintf(stderr, "Couldn't get time\n");
	exit(1);
    }
}
Beispiel #4
0
/* Perform test of combinition function */
static void run_test(lower_t lf, int len)
{
    double time;
    double tpe;
    current_lf = lf;
    setup(len);
    current_lf(data);
    time = fcyc(run, NULL) / mhz(0) * 1e-6;
    tpe = time * 1e6 /(double) len;
    /* print results */
    printf("%d\t%f\t%f\n", len, time, tpe);
}
Beispiel #5
0
int main(void)
{
	int	size;	/* Working set size (in bytes) */
	int	stride;	/* Stride (in array elements) */
	double	Mhz;	/* Clock frequence */

	init_data(data,MAXELEMS);
	Mhz = mhz(0);	/* Estimate the clock frequency */
	for (size = MAXBYTES;size >= MINBYTES;size >> 1){
		for (stride = 1;stride <= MAXSTRIDE;stride ++){
			printf("%.1f\t",run(size,stride,Mhz));
		}
		printf("\n");
	}
	exit(EXIT_SUCCESS);
}
Beispiel #6
0
int main (int argc, char *argv[])
{
  int iters = 1000000;
  double MHz = mhz(1);
  int i;
  int sum = 0;
  double cycs;
  start_counter();
  for (i = 0; i < iters; i++) {
    sum += i;
    cycs = get_counter();
  }
  printf("%d calls in %.0f clock cycles = %.3f usec/call\n",
	 iters, cycs, cycs / (MHz * iters));
  return 0;
}
Beispiel #7
0
int main()
{
	int size;		// working set size(in bytes)
	int stride;
	double Mhz;

	init_data(data, MAXELEMS);
	Mhz = mhz(0); 		// estimate the clock frequency
	for (size = MAXBYTES; size >= MINBYTES; size >>= 1)
	{
		for(stride = 1; stride <= MAXSTRIDE; stride++){
			printf("%.1f\t",run(size, stride, Mhz));
		}
		printf("\n");
	}
	exit(0);
}
Beispiel #8
0
/* $begin mountainmain */
int main()
{
    int size;        /* Working set size (in bytes) */
    int stride;      /* Stride (in array elements) */
    double Mhz;      /* Clock frequency */
    int i;

    init_data(data, MAXELEMS); /* Initialize each element in data to 1 */
    Mhz = mhz(0);  /*             Estimate the clock frequency */
/* $end mountainmain */
    /* Not shown in the text */
    printf("Clock frequency is approx. %.1f MHz\n", Mhz);
    printf("Memory mountain (MB/sec)\n");

    printf("\t");
    for (stride = 1; stride <= MAXSTRIDE; stride++)
	printf("%d\t", stride);
    printf("\n");


    unsigned int sizes[24] = {32*1024*1024, 24*1024*1024, 16*1024*1024, 12*1024*1024, 8*1024*1024, 6*1024*1024, 1024*512+5*1024*1024, 1024*256+5*1024*1024, 5*1024*1024, 4*1024*1024, 2*1024*1024, 1024*1024, 512*1024, 256*1024, (128+64)*1024, 128*1024, 64*1024, 32*1024, 16*1024};

 /* $begin mountainmain */
    for (i=0; i<19; i++){
       size = sizes[i];
	/* Not shown in the text */
	if (size >= (1 << 20))
	    printf("%.1fM  ", (float)size / (float)(1 << 20));
	else
	    printf("%.1fK   ", (float)size / (float)1024);

/* $begin mountainmain */
	for (stride = 1; stride <= MAXSTRIDE; stride++) {
	    printf("%.1f    ", run(size, stride, Mhz));
	}
	printf("\n");
    }
    exit(0);
}
Beispiel #9
0
/*
 * init_fsecs - initialize the timing package
 */
void init_fsecs(void)
{
	Mhz = 0; /* keep gcc -Wall happy */

#if USE_FCYC
	if (verbose)
		printf("Measuring performance with a cycle counter.\n");

	/* set key parameters for the fcyc package */
	set_fcyc_maxsamples(20); 
	set_fcyc_clear_cache(1);
	set_fcyc_compensate(1);
	set_fcyc_epsilon(0.01);
	set_fcyc_k(3);
	Mhz = mhz(verbose > 0);
#elif USE_ITIMER
	if (verbose)
		printf("Measuring performance with the interval timer.\n");
#elif USE_GETTOD
	if (verbose)
		printf("Measuring performance with gettimeofday().\n");
#endif
}
Beispiel #10
0
int main()
{
    double ctime,ptime,mhzest;
    pid_t pid;
    
    /* get estimate of mhz rating of cpu */
    mhzest = mhz();
    start_counter();
    if ((pid = fork()) == 0)
    {
	ctime = dget_counter();
	printf("Child:  %.8d ticks (%.2f ms)\n", (int) ctime, 
	       ctime/(mhzest * 1e3));
	exit(0);
    }
    else
    {
	ptime = dget_counter();
	printf("Parent: %.8d ticks (%.2f ms)\n", (int) ptime,
	       ptime/(mhzest * 1e3));
	waitpid(pid,NULL,0);
    }
}
Beispiel #11
0
int main(int argc, char* args[]){
    mhz(1,1);    
}
Beispiel #12
0
double mhz_full(int verbose, int sleeptime) {
    return mhz(verbose);
}
Beispiel #13
0
int main()
{
	mhz(1,1);
	return 0;
}