1 /* 2 * cputest.c 3 * 4 * WARNING! Always test on a 100% idle system. Note that some tests 5 * may return 0 or negative results, due to pipeline effects. 6 * 7 * $DragonFly: src/test/cpuperf/cputest.c,v 1.1 2004/02/09 18:08:54 dillon Exp $ 8 */ 9 10 #include "blib.h" 11 12 extern char test_str[]; 13 14 int junk; 15 16 int 17 main(int ac, char **av) 18 { 19 int i; 20 int ttl; 21 int us1; 22 int us2; 23 24 printf("CPUTEST %s\n", test_str); 25 start_timing(); 26 for (i = 0; ; ++i) { 27 test_load(&junk); 28 if ((i & 65535) == 0 && get_timing() > 1000000) 29 break; 30 } 31 ttl = i * 4; 32 start_timing(); 33 for (i = 0; i < ttl; ++i) { 34 test_dummy(&junk); 35 } 36 us1 = get_timing(); 37 start_timing(); 38 for (i = 0; i < ttl; ++i) { 39 test_load(&junk); 40 } 41 us2 = get_timing(); 42 stop_timing2(ttl, us2 - us1, "instruction overhead:"); 43 return(0); 44 } 45 46