Getting more execution time when using arm_math.h then math.h?
Hello,
I have created one function to calculate mean of 20 samples of float and run it using math.h and another function using arm_math mean function and check the execution time by making GPIO on and off. I am getting more exeution time for arm math function when compare to normal mean calculation.Why?
Below is the code I am using to check the execution time. I have set the optimization to O2.
//arm math function
float arm_mean (const float x[768])
{
volatile float32_t offset_mean;
arm_mean_f32(x, 20, &offset_mean);
printf("%f\n",offset_mean);
return offset_mean;
}
//math function
float mean( const float x[768])
{
volatile float32_t offset_mean;
float sum = 0.0;
for(int i = 0; i < 20; i++)
{
sum += x[i];
}
// Calculate the mean offset
offset_mean = sum / 20.0;
printf("%f\n",offset_mean);
return offset_mean;
}
int main(){
// Initializations
while(1){
GPIO_OutSet(gpio_test_pin.port, gpio_test_pin.mask);
#if 1
offset_mean = mean(input_array);
#else
offset_mean = arm_mean(const float x[768])
#endif
GPIO_OutClr(gpio_test_pin.port, gpio_test_pin.mask);
}
}
For arm_mean ,
--> 10 us ( for 20 samples)
--> 203 us( for 700 samples)
for mean
--> 5 us (for 20 samples)
--> 79 us( for 700 samples)
As per the study, the arm_math function takes less time when compare to math function. Correct me if wrong?
