Which is faster for large "for" loop: function call or inline coding?

Posted by zaplec on Stack Overflow See other posts from Stack Overflow or by zaplec
Published on 2010-05-04T19:54:28Z Indexed on 2010/05/04 19:58 UTC
Read the original article Hit count: 237

Hi,

I have programmed an embedded software (using C of course) and now I'm considering ways to improve the running time of the system. The most important single module in my system is one very large nested for loop module.

That module consists of two nested for loops that loops max 122500 times. That's not very much yet, but the problem is that inside that nested for loop I have a function call to a function that is in another source file. That specific function consists mostly of two another nested for loops which loops always 22500 times. So now I have to make a function call 122500 times.

I have made that function that is to be called a lot lighter and shorter (yet still works as it should) and now I started to think that would it be faster to rip off that function call and write that process directly inside those first two for loops?

The processor in that system is ARM7TDMI and its frequency is 55MHz. The system itself isn't very time critical so it doesn't have to be real time capable. However the faster it can process its duties the better.

Also would it be also faster to use while loops instead of fors? And any piece of advice about how to improve the running time is appreciated.

-zaplec

© Stack Overflow or respective owner

Related posts about c

    Related posts about runtime