juani_c 66 Posted May 28, 2011 Share Posted May 28, 2011 suppose I have to calcule this; y=(((x2-x1)+(x3-x1))/3)+x1; and I want to know how to break it down in order to have the best code in C. Does anyone know of any good resources for learning how to optimize this kind of tasks? Quote Link to post Share on other sites
bluehash 1,581 Posted May 29, 2011 Share Posted May 29, 2011 There is a book known as The Hackers Delight. It dies not address optimization directly,but the tricks in there will surely help. Do you want to optimize for code or speed? juani_c 1 Quote Link to post Share on other sites
juani_c 66 Posted May 29, 2011 Author Share Posted May 29, 2011 I would like to make it as fast as possible. I'll try to find that book. Thanks! Quote Link to post Share on other sites
rockets4kids 204 Posted May 29, 2011 Share Posted May 29, 2011 In an equation like this, the time-killer is the division. One divide will take far more cycles than all the rest combined, no matter how well optimized. If you are diving by a constant, look into a "fast divide" routine. Here is an example: http://www.hackersdelight.org/divcMore.pdf juani_c and gatesphere 2 Quote Link to post Share on other sites
juani_c 66 Posted May 30, 2011 Author Share Posted May 30, 2011 In an equation like this, the time-killer is the division.f Having this in mind I did a little search and found this; "Efficient Multiplication and Division Using MSP430"-> http://focus.ti.com/lit/an/slaa329/slaa329.pdf There is a table on page 7 showing the results from using different methods and there is a big improvement using those described in the app note. jsolarski, bluehash and GeekDoc 3 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.