--- nono/m680x0/testacc.cpp 2026/04/29 17:05:26 1.1.1.6 +++ nono/m680x0/testacc.cpp 2026/04/29 17:05:57 1.1.1.8 @@ -5,7 +5,8 @@ // #include "mpu680x0.h" -#include "m68030acc.h" +#include "m680x0acc.h" +#include "stopwatch.h" #include #include @@ -21,7 +22,7 @@ static int total_errcnt; // ç·ã‚¨ãƒ©ã static int errcnt; // ç¾åœ¨ã®ã‚»ã‚¯ã‚·ãƒ§ãƒ³ã®ã‚¨ãƒ©ãƒ¼æ•° static char where[256]; // エラー発生箇所 static volatile int perf_signaled; // パフォーマンス測定用 -static struct timeval perf_start; // パフォーマンス測定開始時刻 +static Stopwatch sw; // パフォーマンス測定用 static uint64 perf_count; // パフォーマンス測定用。処ç†å›žæ•° // value ã‚’16é€²æ•°ã§æŒ‡å®šã®ãƒ“ãƒƒãƒˆæ•°åˆ†ã®æ–‡å­—列ã«ã™ã‚‹ @@ -61,7 +62,7 @@ xp_equal(uint32 expected, uint32 actual, // 値(32bitã¾ã§)㨠CCR を検査ã™ã‚‹ static void -xp_equal(uint32 actValue, m68030ccr& actCCR, uint32 expValue, +xp_equal(uint32 actValue, m680x0CCR& actCCR, uint32 expValue, bool expX, bool expN, bool expZ, bool expV, bool expC) { if (expValue != actValue || @@ -95,7 +96,7 @@ xp_equal(uint32 actValue, m68030ccr& act // 値(64bit)㨠CCR を検査ã™ã‚‹ static void __unused -xp_equal64(uint64 actValue, m68030ccr& actCCR, uint64 expValue, +xp_equal64(uint64 actValue, m680x0CCR& actCCR, uint64 expValue, bool expX, bool expN, bool expZ, bool expV, bool expC) { if (expValue != actValue || @@ -215,19 +216,16 @@ start_perf_func(const char *name) struct itimerval it = {}; it.it_value.tv_sec = PERF_SEC; - gettimeofday(&perf_start, NULL); + sw.Restart(); setitimer(ITIMER_REAL, &it, NULL); } static void end_perf_func() { - struct timeval end, result; + sw.Stop(); - gettimeofday(&end, NULL); - timersub(&end, &perf_start, &result); - - uint64 usec = (uint64)result.tv_sec * 1000000 + (uint64)result.tv_usec; + uint64 usec = nsec_to_usec(sw.Elapsed_nsec()); printf("%" PRIu64 " times/usec\n", perf_count / usec); } @@ -284,7 +282,7 @@ static uint32 add_table[] = { }; static void -test_add(m68030acc& acc, int sz) +test_add(m680x0ACC& acc, int sz) { for (int i = 0; i < countof(add_table); i++) { for (int j = 0; j < countof(add_table); j++) { @@ -314,7 +312,7 @@ test_add(m68030acc& acc, int sz) } static void -test_add_8(m68030acc& acc) +test_add_8(m680x0ACC& acc) { start_test(); test_add(acc, 8); @@ -322,7 +320,7 @@ test_add_8(m68030acc& acc) } static void -test_add_16(m68030acc& acc) +test_add_16(m680x0ACC& acc) { start_test(); test_add(acc, 16); @@ -330,7 +328,7 @@ test_add_16(m68030acc& acc) } static void -test_add_32(m68030acc& acc) +test_add_32(m680x0ACC& acc) { start_test(); test_add(acc, 32); @@ -338,7 +336,7 @@ test_add_32(m68030acc& acc) } static void -test_sub(m68030acc& acc, int sz) +test_sub(m680x0ACC& acc, int sz) { for (int i = 0; i < countof(add_table); i++) { for (int j = 0; j < countof(add_table); j++) { @@ -375,7 +373,7 @@ test_sub(m68030acc& acc, int sz) } static void -test_sub_8(m68030acc& acc) +test_sub_8(m680x0ACC& acc) { start_test(); test_sub(acc, 8); @@ -383,7 +381,7 @@ test_sub_8(m68030acc& acc) } static void -test_sub_16(m68030acc& acc) +test_sub_16(m680x0ACC& acc) { start_test(); test_sub(acc, 16); @@ -391,7 +389,7 @@ test_sub_16(m68030acc& acc) } static void -test_sub_32(m68030acc& acc) +test_sub_32(m680x0ACC& acc) { start_test(); test_sub(acc, 32); @@ -417,7 +415,7 @@ static struct { }; static void -test_addx_32(m68030acc& acc) +test_addx_32(m680x0ACC& acc) { start_test(); for (int i = 0; i < countof(addx32_table); i++) { @@ -446,7 +444,7 @@ test_addx_32(m68030acc& acc) // ローテート/シフト系ã®ãƒ‘フォーマンス測定 #define DEFINE_PERF_ROTATE(name) \ static void \ -__CONCAT(perf_,name)(m68030acc& acc) \ +__CONCAT(perf_,name)(m680x0ACC& acc) \ { \ START_PERF; \ volatile uint32 dst = 0; \ @@ -470,7 +468,7 @@ DEFINE_PERF_ROTATE(roxr_32) DEFINE_PERF_ROTATE(ror_32) static void -perf_add_32(m68030acc& acc) +perf_add_32(m680x0ACC& acc) { START_PERF; volatile uint32 dst = 0; @@ -509,8 +507,8 @@ main(int ac, char *av[]) argc = ac; argv = av; - std::unique_ptr accptr(new m68030acc()); - m68030acc& acc = *(accptr.get()); + std::unique_ptr accptr(new m680x0ACC()); + m680x0ACC& acc = *(accptr.get()); if (do_test) { test_add_8(acc);