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