Page 1 of 1

Macro VS. Procedures?

Posted: Sat Aug 19, 2006 1:30 pm
by ToastEater
I Know macros are the compiler simply replacing the source code before the real compileing process appear.
I know to large functions procedures must take place and to the smaller onces a macro can be much faster. But when is it a large function and need procedure?

Asking about speed and size.

Regards

Posted: Sat Aug 19, 2006 8:30 pm
by kinglestat
Hi ToastEater,

As in most things in life I guess its a question of balance and control
And as a decision is more likely to emerge when optimizing your code

I think sometimes its more worth avoiding stuff like multiple-dimensional arrays and anything which is beyond your control to really optimize.

I'm a new user to PureBasic....but I'm a 2nd generation core C programmer, where my job was to optimize (other programmers) code. I have seen that many of the old "tricks" are hardly used any more but with some thought you can truly speed things up

Eg strings are a crippler as they are not native to any processor. Fastest operations are with longs usually 1-3 clock cycles with CISC processors. Thus using a pointer to a string when doing many opeartions on string help (eg sorting an array of pointers as opposed to sorting an array oof strings)

of course as a wise man once said
opinions are like assholes...everybody's got one
and pardon my french

Posted: Sun Aug 20, 2006 1:59 am
by ToastEater
kinglestat wrote:Hi ToastEater,

As in most things in life I guess its a question of balance and control
And as a decision is more likely to emerge when optimizing your code

I think sometimes its more worth avoiding stuff like multiple-dimensional arrays and anything which is beyond your control to really optimize.

I'm a new user to PureBasic....but I'm a 2nd generation core C programmer, where my job was to optimize (other programmers) code. I have seen that many of the old "tricks" are hardly used any more but with some thought you can truly speed things up

Eg strings are a crippler as they are not native to any processor. Fastest operations are with longs usually 1-3 clock cycles with CISC processors. Thus using a pointer to a string when doing many opeartions on string help (eg sorting an array of pointers as opposed to sorting an array oof strings)

of course as a wise man once said
opinions are like assholes...everybody's got one
and pardon my french
hehehe
I know i know but mean how long time does it take to the function like

jmp myfunction ; should i do this? and how long does it take to jump to myfunction: label


..
..
.. ; or should i just do my few lines code here


myfunction:
..
..
..
Retn


I know how to program very small lines of assembler, but haven't seen anything there was converted to asm there would use a function :o like does it push pointers to the variables intro the stack and how much it uses ? i know its small im asking about but still some of my code would be done so much easier with macro's but would it take to much for do it :o


sorry again and always for my bad english :oops:


Thanks a ton