[app][bench] add some quick n dirty sin/cos/sqrt benchmarks if libm is built

This commit is contained in:
Travis Geiselbrecht
2014-08-20 17:41:11 -07:00
parent e450ea7e72
commit afead3d125

View File

@@ -176,6 +176,42 @@ void bench_memcpy(void)
}
#endif
#if WITH_LIB_LIBM
#include <math.h>
__NO_INLINE static void bench_sincos(void)
{
printf("touching the floating point unit\n");
__UNUSED volatile double _hole = sin(0);
uint count = arch_cycle_count();
__UNUSED double a = sin(2.0);
count = arch_cycle_count() - count;
printf("took %u cycles for sin()\n", count);
count = arch_cycle_count();
a = cos(2.0);
count = arch_cycle_count() - count;
printf("took %u cycles for cos()\n", count);
count = arch_cycle_count();
a = sinf(2.0);
count = arch_cycle_count() - count;
printf("took %u cycles for sinf()\n", count);
count = arch_cycle_count();
a = cosf(2.0);
count = arch_cycle_count() - count;
printf("took %u cycles for cosf()\n", count);
count = arch_cycle_count();
a = sqrt(1234567.0);
count = arch_cycle_count() - count;
printf("took %u cycles for sqrt()\n", count);
}
#endif
void benchmarks(void)
{
#if ARCH_ARM
@@ -189,5 +225,8 @@ void benchmarks(void)
bench_cset_stm();
bench_memcpy();
#endif
#if WITH_LIB_LIBM
bench_sincos();
#endif
}