I need to know which of the scenarios will take the larger performance hit in a script. Time to complete is critical:
Common Background:
a uint8 array containing at least 8 elements
need to get the data back to parameter variables to sent via FFCAN
Scenario 1:
Use smWrite function calls to write each byte to a parameter variable -- This requires at least 16 function calls (8 smWrite and 8 smGetHandle) and data conversion to double for each. Assign a variable to each byte of the FFCAN message.
Scenario 2:
Convert and combine data to get two 4 byte numbers, convert to doubles and use only 2 smWrite function calls (and 2 smGetHandle). Assign a high and low variable to the first and last 4 bytes of the FFCAN message respectively.
Function call penalty
- mbowdich
- Posts: 209
- Joined: Tue Oct 05, 2010 10:54 am
- dwills
- Enovation Controls Development
- Posts: 26
- Joined: Fri Jul 30, 2010 8:27 am
Re: Function call penalty
Scenario 2 will take less time, if the data manipulation required is not too extensive. The write calls have the potential to pend on a mutex protecting the database, so the fewer of these, the less chance of pending the script and allowing it to run to completion. There would have to be substantial manipulation of the data to equal the context switch caused when the script pends.
As another note, the handles assigned to variables are static. In critical code, it is better to initialize the handle values once, and not bear the overhead of repeated calls to get the handles.
As another note, the handles assigned to variables are static. In critical code, it is better to initialize the handle values once, and not bear the overhead of repeated calls to get the handles.
- mbowdich
- Posts: 209
- Joined: Tue Oct 05, 2010 10:54 am
Re: Function call penalty
Thanks. That is also the scenario I figured would work the best.
Unfortunately, the getHandle call needs to be done more than once in this case, as I do not know what handle needs to be called at compile time. There is another function in the script that determines this durng runtime. I know I take a substantial hit for the call, but I am trying to de this as little as possible (1-2 times per call).
Unfortunately, the getHandle call needs to be done more than once in this case, as I do not know what handle needs to be called at compile time. There is another function in the script that determines this durng runtime. I know I take a substantial hit for the call, but I am trying to de this as little as possible (1-2 times per call).