[app][bench] add some quick n dirty sin/cos/sqrt benchmarks if libm is built
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user