/* ** ram-speed From: AMIGA.4173 ** ** Times memory performance. To be compiled under MANX. ** ** Author: Perry S. Kivolowitz ** */ #include #include #include extern char *AllocMem(); extern struct IntuitionBase *OpenLibrary(); struct IntuitionBase *IntuitionBase; char *source , *destination; long EndingSeconds , EndingMicroSeconds; long StartingSeconds , StartingMicroSeconds; #define BSIZE (1L << 17) /* ** FreeAll ** ** Return any allocated memory back to the system for reuse. ** */ FreeAll() { if (source) FreeMem(source , BSIZE); if (destination) FreeMem(destination , BSIZE); } /* ** AllocAll ** ** Given a type of memory specified by ``bits'' allocate BSIZE ** bytes for a source area and a destination area. ** */ AllocAll(bits) long bits; { destination = AllocMem(BSIZE , bits); source = AllocMem(BSIZE , bits); if (!source || !destination) { printf("Allocation of Memory Failed\n"); Leave(); } } /* ** Leave ** ** Clean up routine. Release memory and close Intuition. ** */ Leave() { /* FreeAll(); */ /* This causes guru meditation 81000009.xxxxxxxx "freeing memory already freed". T.Floryan */ CloseLibrary(IntuitionBase); exit(0); } OpenIntuition() { IntuitionBase = OpenLibrary("intuition.library" , 0L); if (!IntuitionBase) { printf("Could Not Open Intuition\n"); exit(0); } } long PrintTime() { long temp1 , temp2; temp2 = 1000000 * EndingSeconds + EndingMicroSeconds; temp1 = 1000000 * StartingSeconds + StartingMicroSeconds; temp2 = temp2 - temp1; printf("Elapsed Time (microseconds): %ld\n" , temp2); return(temp2); } long TimeRam(bits) long bits; { AllocAll(bits); CurrentTime(&StartingSeconds , &StartingMicroSeconds); CopyRam(); CurrentTime(&EndingSeconds , &EndingMicroSeconds); FreeAll(); return(PrintTime()); } main() { int i; long fast , chip; OpenIntuition(); printf("Timing CHIP Memory\n"); chip = TimeRam(MEMF_CHIP); printf("Timing FAST Memory\n"); fast = TimeRam(MEMF_FAST); printf("Difference (microseconds): %ld\n" , fast - chip); Leave(); } CopyRam() { register long *src , *dst; register short i , j; for (j = 0; j < 256; j++) { src = (long *) source; dst = (long *) destination; i = BSIZE / 32; while (--i) { #asm move.l (a2)+,(a3)+ move.l (a2)+,(a3)+ move.l (a2)+,(a3)+ move.l (a2)+,(a3)+ move.l (a2)+,(a3)+ move.l (a2)+,(a3)+ move.l (a2)+,(a3)+ move.l (a2)+,(a3)+ #endasm } } }