[fpc-pascal] Program efficiency
james.richters at productionautomation.net
Wed Nov 9 13:39:43 CET 2022
I was wondering if breaking up large complicated formulas into smaller
sections that use more variables is less efficient than just the large
In other words.. is
Less efficient than
O:= ((B+C/D)-E^F)+ (H*(I+J))-(L+M/N);
Or does it end up being the same when it's done?
I have a tendency to avoid using variables even though the code would be
infinitely more understandable if it was broken into sections and more
variables were used, but I'm wondering if this is really any more efficient
or if it just seems like it should be... after all storing things in a
variable and reading them out should take some time... but then again the
processor only works on one operation at a time anyway, so the final
assembly code would probably have to store things somewhere and get them
back... so.. is it really faster?
So if I never need the value a second time, is it really better to avoid
I could break it up an use comments:
O:= ((B+C/D)-E^F)+ //A
This got me thinking, it would be cool if there was some king of utility
that counted clock cycles for you while your program ran..and then I could
just try a sample program both ways and see what the results are...
More information about the fpc-pascal