Hi Das,
In fact there is a very small overhead in calling commands or functions. But you have to do it 100.000 times to see a noticeable difference in the range of a couple milliseconds.
I would modularize code as you do if that is helping you to keep it clean and maintainable.
If you are concerned about the overhead you could use "private", this again will reduce a couple of nanoseconds from the overhead. See the dictionary for private.
I usually use inline code only if I want to squeeze out the last bit of speed, like processing imageData or very long lists.
here is a short test that should give you and idea
Code: Select all
on mouseUp
put the milliseconds into t
speedTest1
put the milliseconds - t into time1
put the milliseconds into t
speedTest2 1
put the milliseconds - t into time2
put time1 && time2
end mouseUp
on speedTest1
repeat 100000
add 1 to x
end repeat
end speedTest1
on speedTest2 pNumber
put pNumber into temp
repeat 100000
put addition(temp) into temp
end repeat
end speedTest2
function addition pNumber
add 1 to pNumber
return pNumber
end addition
--private function addition pNumber
-- add 1 to pNumber
-- return pNumber
--end addition
--private function addition @pNumber
-- add 1 to pNumber
-- return pNumber
--end addition
the blocked parts are variations of the function. Unblock to see effect, don't forget to block the ones you don't want to test.
the @ sign means the parameter is passed as reference to the variable and not a new variable -> see @ in the dictionary.
The results will show up in the message box.
I hope this helps a bit.
Kind regards
Bernd