Making variables global instead of local can seriously degrade performance. Not sure on Blitz – but on stack frame processors accessing local variables can be done with small and very efficient instructions where as accessing Global variables required length far or indirect instructions.
I reduced the code size of one program from 64K bytes to 41K Bytes and the execution speed more than doubled at the same time. This was done by using more local variables so allowing the compile to use the processors most efficient memory access every time a variable was used instead of using a larger inefficient access to the global memory space. So I improved the structure of the code, made it more readable, reduced it size by 1/3 and more than doubled it execution speed.
So if you want to butcher your code in the name of optimisation think again, I have seen “professional” programmers in dismay after weeks of code butchering in the name of “optimisation” only to find little improvement and sometimes even total disbelief from them when they find their newly “optimised” code runs slower than it did before.
I reduced the code size of one program from 64K bytes to 41K Bytes and the execution speed more than doubled at the same time. This was done by using more local variables so allowing the compile to use the processors most efficient memory access every time a variable was used instead of using a larger inefficient access to the global memory space. So I improved the structure of the code, made it more readable, reduced it size by 1/3 and more than doubled it execution speed.
So if you want to butcher your code in the name of optimisation think again, I have seen “professional” programmers in dismay after weeks of code butchering in the name of “optimisation” only to find little improvement and sometimes even total disbelief from them when they find their newly “optimised” code runs slower than it did before.