/* Centralized benchmark suite. */ #include "fix.h" #include "std.h" #include "time.h" #include #define TEST(p_e) \ do { \ if (!(p_e)) { \ com_std_print('c', COM_DEF_STRLIT(p_e) " failed!"); \ anyfail = true; \ } \ } while (0) static void com_bnch_fix(void) { uint64_t start = com_timer_count_ns(); for (int i = 5000000; i--;) { com_fix_t sqrt = com_fix_sqrt(i); com_def_profile_sink(sqrt); } com_timer_profile(start, "fixed: sqrt"); start = com_timer_count_ns(); for (int i = 50000000; i--;) { com_fix_t sin = com_fix_sin(i); com_def_profile_sink(sin); } com_timer_profile(start, "fixed: sin"); start = com_timer_count_ns(); for (int i = 50000000; i--;) { com_fix_t cos = com_fix_cos(i); com_def_profile_sink(cos); } com_timer_profile(start, "fixed: cos"); start = com_timer_count_ns(); for (int i = 50000000; i--;) { com_fix_t sin, cos; com_fix_sincos(i, &sin, &cos); com_fix_t sinv = sin; com_fix_t cosv = cos; com_def_profile_sink(sinv); com_def_profile_sink(cosv); } com_timer_profile(start, "fixed: sincos"); } static void com_bnch_run(void) { com_bnch_fix(); } #undef TEST