Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

what makes function execution longer

Status
Not open for further replies.

cyboman

Member level 4
Joined
Mar 9, 2010
Messages
71
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
USA
Activity points
1,808
this is a very generic question.

i have a function written in C and i also have assembly version of the function. the task that i have is to identify places in the function which consume most of the execution cycles and find a way to reduce them. so the question is what usually consumes a lot of execution time, array access, for loops etc.

this is not homework, this is for the task i was assigned at my work.

any help is appreciated
 

this is difficult without seeing the algorithms being used. however, a few things to look for
1. avoid mathematical functions such as sin() and log(), etc, e.g. use lookup tables for sin()
2. in arithmetic expressions division takes far longer than other operations followed by multiply, for divsion and multiplication by 2 use >> and << (but be careful of signed values if >> is logical).
3. with loops look at the algorithm, i.e. are there operations performed each loop that are constants within the loop and could be done before the loop (a good optimising compiler should do this for you)
4. make short functions inline if the compiler supports this or as macros (saves function call and parameter marshaling)
5. avoid multidimensional arrays if possible
6. avoid the excessive use of structures and nested structures (they are a good tool but can be over done)

A good optimising compiler will do a lot of work for you and is often better than a programmer working in assembly language.
Share the load with another processor, e.g. off load the TCP/IP stack to a dedicated device, or use a multiprocessor system.
Examine the algorithm useds and their implementation - a slight change can make orders of magnitude changes in run time.
Drive the processor faster if it has clock multipliers or get a faster processor
For DSP use processors with specialised hardware, e.g. for FFT, filters, etc
Get a computer with a floating proint processor


often using a faster processor is often the simplest answer
 
  • Like
Reactions: Abeer_h

    Abeer_h

    Points: 2
    Helpful Answer Positive Rating
One very simple method is to use a "toggle pin". In order to identify the most consuming part you have to set a pin "HIGH" and on the end of part you want to measure, set pin to "LOW". Measure time with oscilloscope and write it down the measured valued. Do this for each part you think is most likely to last longer. You can apply this task using a "divide et impera" strategy. Good luck. :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top