emuspeed.c revision 1.1
1#include <setjmp.h> 2#include <signal.h> 3#include <stdlib.h> 4#include <stdio.h> 5#include <time.h> 6#include <unistd.h> 7 8#include "speed.h" 9 10const struct test { 11 char *name; 12 void (*func)__P((int)); 13 char *comment; 14 int count; 15} testlist[] = { 16 {"Illegal", illegal, "(test: unimplemented)", 1}, 17 {"mulsl Da,Db", mul32sreg, "(test: should be native)", 200000000}, 18 {"mulsl sp@(8),Da", mul32smem, "(test: should be native)\n", 19 200000000}, 20 21 {"mulsl Dn,Da:Db", mul64sreg, "emulated on 68060", 2000000}, 22 {"mulul Dn,Da:Db", mul64ureg, "\t\"", 2000000}, 23 {"mulsl sp@(8),Da:Db", mul64smem, "\t\"", 1000000}, 24 {"mulul sp@(8),Da:Db", mul64umem, "\t\"\n", 1000000}, 25 26 {"divsl Da:Db,Dn", div64sreg, "\t\"", 500000}, 27 {"divul Da:Db,Dn", div64ureg, "\t\"", 500000}, 28 {"divsl Da:Db,sp@(8)", div64smem, "\t\"", 300000}, 29 {"divul Da:Db,sp@(8)", div64umem, "\t\"\n", 300000}, 30 31 {NULL, NULL, NULL} 32}; 33 34jmp_buf jbuf; 35void illhand (int); 36 37int 38main(argc, argv) 39 int argc; 40 char *argv[]; 41{ 42 const struct test *t; 43 clock_t start, stop; 44 45 46 if (signal(SIGILL, &illhand)) 47 warn("%s: can't install illegal instruction handler.", 48 argv[0]); 49 50 printf("Speed of instructions which are emulated on some cpus:\n\n"); 51 (void)sleep(1); 52 for (t=testlist; t->name; t++) { 53 printf("%-20s", t->name); 54 fflush(stdout); 55 56 if (setjmp(jbuf)) { 57 printf("%15s %s\n", "[unimplemented]", t->comment); 58 continue; 59 } 60 61 start = clock(); 62 t->func(t->count); 63 stop = clock(); 64 printf("%13d/s %s\n", 65 CLOCKS_PER_SEC*(t->count /(stop - start)), 66 t->comment); 67 } 68 exit (0); 69} 70 71void 72illhand(int i) 73{ 74 longjmp(jbuf, 1); 75} 76