Date: Sun, 9 Jul 1995 00:54:28 -0400 (EDT) From: "Jonathan M. Bresler" <jmb@kryten.Atinc.COM> To: "Serge A. Krashakov" <sakr@itp.ac.ru> Cc: hackers@freebsd.org Subject: ramspeed.c Message-ID: <Pine.3.89.9507090058.K11845-0100000@kryten.atinc.com>
next in thread | raw e-mail | index | archive | help
here it is Jonathan M. Bresler jmb@kryten.atinc.com | Analysis & Technology, Inc. FreeBSD Postmaster jmb@FreeBSD.Org | 2341 Jeff Davis Hwy play go. | Arlington, VA 22202 ride bike. hack FreeBSD.--ah the good life | 703-418-2800 x346 /* ** ramspeed--Poul-Henning Kamp <phk@login.dknet.dk> ** ** ** */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <memory.h> #include <sys/types.h> #include <sys/time.h> typedef unsigned long test_t; #define TESTSIZE (8192*1024) #define NOPS 1024*1024*16 #define NFACTOR 11 #define NVOL (NOPS*NFACTOR) int main(int argc,char **argv) { test_t *area, *chunk; test_t *pointer,x1=0,x2=0; unsigned counter,leap; int i; double delta; struct timeval before,middle,after; struct timezone tzb,tza; if (sizeof *area != 4) { perror("Need 32 bit test_t"); exit(2); } pointer = area=malloc(TESTSIZE); if(!area) { perror("malloc"); exit(2); } memset(area,'D',TESTSIZE); chunk = area + TESTSIZE / sizeof *area - 102; leap = TESTSIZE / sizeof *area - 204; gettimeofday(&before,&tzb); for(counter=0;counter<NOPS;counter++) { #define ZAP(x) x1 += *pointer; pointer += x; ZAP(1); ZAP(2); ZAP(3); ZAP(5); ZAP(7); ZAP(11); ZAP(13); ZAP(17); ZAP(19); ZAP(23); *pointer += x1; #undef ZAP if(pointer >= chunk) { pointer -= leap; } } gettimeofday(&middle,&tza); for(counter=0;counter<NOPS;counter++) { #define ZAP(x) *pointer = x2++ ; pointer += x; ZAP(1); ZAP(2); ZAP(3); ZAP(5); ZAP(7); ZAP(11); ZAP(13); ZAP(17); ZAP(19); ZAP(23); x2 = *pointer; #undef ZAP if(pointer >= chunk) { pointer -= leap; } } gettimeofday(&after,&tza); if (x1 != 0x49005fb0) {perror("Wrong result"); exit(1); } if (x2 != 0x8938c0df) {perror("Wrong result"); exit(1); } delta =middle.tv_sec - before.tv_sec; delta +=(middle.tv_usec - before.tv_usec)/1000000.0; printf("%08lx ",x1); printf(" %6.3f uS/op", delta*1000000.0/NVOL); printf(" %7.2e op/S", NVOL/delta); printf(" %6.3f Mb/S\n", (NVOL*sizeof *pointer/(1024.0*1024.0)) / delta); delta =after.tv_sec - middle.tv_sec; delta +=(after.tv_usec - middle.tv_usec)/1000000.0; printf("%08lx ",x2); printf(" %6.3f uS/op", delta*1000000.0/NVOL); printf(" %7.2e op/S", NVOL/delta); printf(" %6.3f Mb/S\n", (NVOL*sizeof *pointer/(1024.0*1024.0)) / delta); return 0; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.3.89.9507090058.K11845-0100000>