home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
drdobbs
/
1987
/
12
/
deikman
/
test.c
< prev
Wrap
Text File
|
1987-12-21
|
2KB
|
60 lines
#include <stdio.h>
#include "cache.h"
CACDS *cache;
main() {
printf("Cache test routine\n");
cache = cacallo(8, 128, (char *) 0, 1L);
printf("Memory allocated = %ld\n\n", cacamem);
while (ctest()) cprint();
exit(0); }
int ctest() {
int opt, rec;
long num;
printf("\n1=old, 2=num, 3=find, 4=proc: ");
scanf("%d", &opt);
switch (opt) {
case 0: return 0;
case 1: printf("cacold returns %lx\n", cacold(cache)); return 1;
case 2: printf("enter record: ");
scanf("%ld", &num);
printf("cacnum returned %lx\n", cacnum(cache, num));
return 1;
case 3: printf("input record to find: ");
scanf("%ld", &num);
printf("cacfind returned %lx\n", cacfind(cache, num));
return 1;
case 4: printf("input record to process: ");
scanf("%ld", &num);
cacproc(cache, num);
printf("cacproc called\n");
return 1;
otherwise: return 1; }
return; }
cprint() {
register int i;
printf("Cache print: hits=%ld miss=%ld adds=%ld\n",
cache->hits, cache->miss, cache->adds);
printf("Block Numbers Next Prior Mark LRU=%d MRU=%d\n", cache->lru, cache->mru);
printf("----- ------- ----- ----- -----\n");
for (i = 0; i < cache->maxr; i++)
printf("%5d %7ld %5d %5d %4d\n", i, cache->nums[i],
cache->next[i],
cache->prio[i],
cache->mark[i]);
return; }