Just did some good optimisation by having two copies of a function which I could test 100,000 times via two different key presses. Then I optimised one of them and got the time down.
However, one of the optimisations I tried didn't work, it was slower in fact. In this thread: http://www.blitzbasic.com/Community/posts.php?topic=76454 I talked about having a method with 10 params that I call in a loop from another method and if it would be quicker to have no params and use Global variables (well actually fields on the type that the method is part of) instead. Well I tried it out and the fields method was slightly slower! I conclude this is because fields/globals are basically in "slow memory" i.e not the CPU registers or stack or cache or something and so it's actually faster to pass tons of local variables into a method instead of using globals. Worth knowing that this is a false optimisation as I won't bother in the future.
However, one of the optimisations I tried didn't work, it was slower in fact. In this thread: http://www.blitzbasic.com/Community/posts.php?topic=76454 I talked about having a method with 10 params that I call in a loop from another method and if it would be quicker to have no params and use Global variables (well actually fields on the type that the method is part of) instead. Well I tried it out and the fields method was slightly slower! I conclude this is because fields/globals are basically in "slow memory" i.e not the CPU registers or stack or cache or something and so it's actually faster to pass tons of local variables into a method instead of using globals. Worth knowing that this is a false optimisation as I won't bother in the future.