0
\$\begingroup\$

I was doing a performance monitoring for my sine function and interestingly when I use the variable a in the sine as 16 bit unsigned types it takes more time to calculate than when I use the same variable as a 32 bit unsigned. Could this be because inside the sine algorithm in math.h/.c it takes more time to type caste the 16 bit type ??

This is how my operation looks like, start_performance, for(50 times) { a=sin(a*3.14/180); } stop_performance_and_read values

My performance monitoring unit works fine , its just that I dont understand why the result is odd.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

You don't say what processor this is running on. If it's a 32 bit machine, then calculations are most likely done on 32 bit values, and converting to/from 16 bit takes extra cycles.

I once did a benchmark test on a IBM workstation that had double precision floating point hardware. Double precision (64 bit) floating point calculations took longer than 32 bit.

\$\endgroup\$
1
  • \$\begingroup\$ Ahh! Thats exactly it then !! Thank you so much !! Got it ! :) I am using a 32 bit ARM A9 processor ! \$\endgroup\$ Apr 30, 2016 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.