Hello, Guest the thread was called282 times and contains 2 replays

last post from GoDot at the

Test of the influence of line numbers on the speed of a MEGA65 BASIC program

  • "The influence of line numbers on the speed of a MEGA65 BASIC program with GOTO command" would be a more typical title for a diploma thesis. But it is exactly what I tried yesterday. :)


    During my occupation with C65-ROM I had the idea to try out if and which influence the line numbers have on the speed of a BASIC program.


    I wrote a short program that loops 30,000 times, in which there are three GOTO jumps. Two "forward" and one "backward":



    I have the time in seconds displayed, which is needed for the execution of the program on the Nexys board.


    The first column contains the line number of the first program line. In the second column the step size to the next program line. "10,10" means for example that I numbered the program with RENUMBER 10,10. The first line is the 10, then comes the 20, then the 30, etc.


    In the third column is the time taken by the Nexys board with ROM 911210. In the fourth column the needed time with the current newest ROM 920183 (you can load the patchfile for it here at the filehoster).


    At this point I would like to point out again that the increased speed of BASIC 65 (in the new ROM) compared to BASIC 10 of the original ROM is really very impressive. The used test program runs with it in all variants around approx. 80% (!) faster. Hats off for this achievement of the MEGA team (especially to Bit Shifter for his work on the ROM)! :thumbup:


    What stood out in this test is that the line numbers used and also the line step size have a significant impact on the processing speed of the program.


    With both ROMs the variant "1,1" (from line number 1 with step size 1) is the fastest variant.


    With the 911210 ROM



    it is 39% faster than the slowest variant ("50000,256").





    And with the 920183 ROM it is about 23.5% faster



    than the slowest variant ("25000,10").




    That is, one can optimize alone by the change of the line numbering (in BASIC 10 or BASIC 65) uncomplicated with RENUMBER <start>,<increment>, its BASIC program on speed. At least, if the GOTO command is used in the program (which is not so unusual in BASIC ;) ).


    Here are the detailed tables and a few thoughts about:


    The table sorted by start linenumber and increment:




    The table sorted by the used time with the 911210 ROM. 0,00% in the yellow column means that this is the slowest variant and the percent values show how many percent the variant in this line runs faster than the slowest variant.



    And here the table sorted by the used time with the 920183 ROM. 0,00% in the yellow column means again that this is the slowest variant and the percent values show how many percent the variant in this line runs faster than the slowest variant.




    One interesting point is that the sequence of "faster than" is not the same with the 911210 and the 920183 ROM. The percent values differ in the variants.

  • Snoopy

    Changed the title of the thread from “Test of the influence of linenumbers on the speed of a MEGA65 BASIC program” to “Test of the influence of line numbers on the speed of a MEGA65 BASIC program”.
  • Very impressive investigation and presentation !

    Thanks Snoopy