So it wasn't the best way to do it

After I’ve published the previous post, I was talking to TCD on #awesome BBS chat, and he suggested me use something else to position the cursor:

50000 PRINT LEFT$(“{home}{25 x down}”,y) SPC(x);

And to call the function, I could use:


My first answer was: “Well, that’s cool but I think my POKEs are faster!“. He then made a good point about the high cost of the string functions I was using. Intrigued, I decide to run some tests comparing both ideas. The benchmark would simply assign 100 random positions to two arrays and print them using both methods. I’d be using the TI command to get the time at the beginning and the end of each function.

The random coordinates were used because my theory was that if the command above has to print, for example, 24 downs and 40 spaces it would take longer than print just few positions from where the cursor would be. On the other hand, the poke commands would go directly to the point!

To my surprise, on the first run, TCD’s method above was twice as fast as the POKE commands from my previous post. String functions fault!.. Right!? Actually wrong… Even passing the X and Y coordinates ready to be used in the function to avoid all string commands, the POKE method was still 50% slower.

That was an interesting discovery for me. Now I’m convinced!


Author: Paulo Garcia

Leave a Reply

Your email address will not be published. Required fields are marked *