Hello
I am measuring the time between a series of calculations in my code. It takes almost 0.0003 s to run this piece of code:
StartTimer();
vol1 = voltage*3/4095;
cur1 = current*3/4095;
sum1=W[0]*phi1(f1_1(cur1,vol1),f1_2(cur1,vol1),fmod(t1,1)+dt)+W[1]*phi4(f1_1(cur1,vol1),f1_2(cur1,vol1),fmod(t1,1)+dt)+W[2]*phi5(f1_1(cur1,vol1),f1_2(cur1,vol1),fmod(t1,1)+dt)+W[3]*phi6(f1_1(cur1,vol1),f1_2(cur1,vol1),fmod(t1,1)+dt)+W[4]*phi16(f1_1(cur1,vol1),f1_2(cur1,vol1),fmod(t1,1)+dt)+W[5]*phi32(f1_1(cur1,vol1),f1_2(cur1,vol1),fmod(t1,1)+dt)+W[6]*phi33(f1_1(cur1,vol1),f1_2(cur1,vol1),fmod(t1,1)+dt);
sum2=W[0]*phi1(f2_1(cur1,vol1),f2_2(cur1,vol1),fmod(t1,1)+dt)+W[1]*phi4(f2_1(cur1,vol1),f2_2(cur1,vol1),fmod(t1,1)+dt)+W[2]*phi5(f2_1(cur1,vol1),f2_2(cur1,vol1),fmod(t1,1)+dt)+W[3]*phi6(f2_1(cur1,vol1),f2_2(cur1,vol1),fmod(t1,1)+dt)+W[4]*phi16(f2_1(cur1,vol1),f2_2(cur1,vol1),fmod(t1,1)+dt)+W[5]*phi32(f2_1(cur1,vol1),f2_2(cur1,vol1),fmod(t1,1)+dt)+W[6]*phi33(f2_1(cur1,vol1),f2_2(cur1,vol1),fmod(t1,1)+dt);
sum3=W[0]*phi1(f3_1(cur1,vol1),f3_2(cur1,vol1),fmod(t1,1)+dt)+W[1]*phi4(f3_1(cur1,vol1),f3_2(cur1,vol1),fmod(t1,1)+dt)+W[2]*phi5(f3_1(cur1,vol1),f3_2(cur1,vol1),fmod(t1,1)+dt)+W[3]*phi6(f3_1(cur1,vol1),f3_2(cur1,vol1),fmod(t1,1)+dt)+W[4]*phi16(f3_1(cur1,vol1),f3_2(cur1,vol1),fmod(t1,1)+dt)+W[5]*phi32(f3_1(cur1,vol1),f3_2(cur1,vol1),fmod(t1,1)+dt)+W[6]*phi33(f3_1(cur1,vol1),f3_2(cur1,vol1),fmod(t1,1)+dt);
if ((sum1<=sum2) && (sum1<=sum3)) {
Gpio_setup1();
}
else if ((sum2<=sum1) && (sum2<=sum3)) {
Gpio_setup2();
}
else {
Gpio_setup3();
}
StopTimer();
As seen, I am calling 3*21 functions, doing a multiplication and then choosing a minimum. I know this way, I am not using rich strategies of C programming. So my question is how can I call these function and do these calculations faster?
Best,
Ata
