Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * bogo.c
- * measure bogoMIPS
- *
- * sc ansi errorrexx math=standard lib=lib:amiga.lib bogo.c link to bogo
- */
- #include <exec/types.h>
- #include <exec/exec.h>
- #include <intuition/intuition.h>
- #include <graphics/gfx.h>
- #include <dos/dos.h>
- #include <clib/timer_protos.h>
- #include <devices/timer.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/timer.h>
- #include <proto/alib.h>
- #include <intuition/intuition.h>
- #include <clib/timer_protos.h>
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- #include <math.h>
- char *vers = "\0$VER: bogoMIPS v1.4 (15.10.2023)"; /* Version string */
- char *stacksize = "$STACK:32000"; /* only works when started from CLI */
- struct IntuitionBase *IntuitionBase; /* Zeiger auf IntuitionBase-Struktur */
- struct GfxBase *GfxBase; /* Zeiger auf GfxBase-Struktur */
- struct Device *TimerBase;
- static struct IORequest timereq;
- ULONG t;
- /* --- Fuction proto types --- */
- static void delay(unsigned int loops);
- ULONG getBogoTime(void);
- static void delay(unsigned int loops);
- /*
- * Function: delay(void)
- * Portable version
- */
- static void delay(unsigned int loops)
- {
- long i;
- for (i = loops; i >= 0 ; i--)
- ; /* do nothing */
- }
- /*
- * Function: getBogoTime(void)
- */
- ULONG getBogoTime(void)
- {
- unsigned long loops_per_sec = 1;
- unsigned long ticks = 0;
- static struct timeval tv; /* is it REALLY initialized correctly? */
- static struct timeval tv2;
- TimerBase = (struct Device *)FindName(&SysBase->DeviceList,"timer.device");
- printf("Calibrating delay loop.. ");
- printf("\nDEBUG: CLOCKS_PER_SEC = %lu", CLOCKS_PER_SEC);
- printf("\nDEBUG: loops_per_second = %lu", loops_per_sec);
- while ((loops_per_sec <= 1))
- {
- printf("\nDEBUG: (in loop)CLOCKS_PER_SEC = %lu", CLOCKS_PER_SEC);
- printf("\nDEBUG: (in loop) loops_per_second = %lu", loops_per_sec);
- /* ERROR: Allways delivers 0 for tv_secs and tv_micro */
- GetSysTime(&tv2);
- delay(loops_per_sec);
- /* ERROR: As above */
- GetSysTime(&tv);
- SubTime(&tv, &tv2);
- printf("\nDEBUG: (in loop) tv_secs = %lu", tv.tv_secs);
- printf("\nDEBUG: (in loop) tv_micro = %lu", tv.tv_micro);
- ticks = (tv.tv_secs*50) + (tv.tv_micro/20000);
- printf("\nDEBUG: (in loop) ticks = %lu\n", ticks);
- if (ticks >= CLOCKS_PER_SEC)
- {
- loops_per_sec = (loops_per_sec / ticks) * CLOCKS_PER_SEC;
- printf("ok - %lu.%02lu BogoMips\n", loops_per_sec/500000, (loops_per_sec/5000) % 100);
- return 0;
- }
- }
- printf("failed\n");
- }
- void main(void)
- {
- ULONG result = 0;
- char c;
- /* Intuition Library öffnen */
- IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 36L);
- /* Graphics Library öffnen */
- GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0L);
- if(!OpenDevice("timer.device", 0, &timereq, 0))
- {
- TimerBase = timereq.io_Device;
- printf("\nDEBUG: (in main) TimerBase = %lu", TimerBase);
- /* give shell a chance to display TimerBase */
- c = getchar();
- result = getBogoTime();
- CloseDevice(&timereq);
- CloseLibrary((struct Library *) GfxBase);
- CloseLibrary((struct Library *) IntuitionBase);
- }
- else
- puts("Device not opened!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement