|
Forum Index : Microcontroller and PC projects : how to make programms in mmbasic faster...
| Author | Message | ||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 240 |
how to make programms in mmbasic faster... on my 40 year old amstrad cpc I am able to optimize speed and i know how to because i wrote the compiler itself. with mmbasic version7 it is so wonderful to speed up the programs, but I want to do that more exactly. on mmbasic I am not sure about the exact method to speed up. Is this question already discussed here in the forum? here my questions (some of many): 1. One command per line or more? (a=b b=c c=d or a=b:b=c:c=d) 2. "for ... next" or loop? (for i=0 to 9 next or i=0 do inc i loop until i>9) 3. "next x" or "next"? I already read: "next" without x correct? 4. complicated expression or variable? (for n=1 to a+b+c+sqr(x)... or m=a+b+c+sqr(x)... for n=1 to m... one question is whether the condition in the for-loop ist calculated every round) 5. constants or numbers? (print 10 or const p=10 ... print p or line 10,10,100,100,,, or x=... y=... x1=... y1=... line x,y,x1,y1,,, ) some parsers are slower by reading a number from the ascii text than getting the value of a var or constant... 6. I read the infos of mmbasic v7...b7: call "subroutine" is faster than "subroutine"? 7. long names of variables? in my old basic dialects programs with long names of vars (etc) are slower because of the need of interpreting. that did not matter after compiling. how in mmbasic (compiled and not compiled)? and so on... |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 240 |
ok. I tested it by a few lines: for to is faster than do loop do loop is faster than goto label I will try further. those who create mmbasic know that much more exact... |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 11974 |
Here you go. This will be included in the next release package MMBasic_Performance_Guide.pdf |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 240 |
that is fine. thank you. |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 240 |
The performance guide is great! perhaps there will be a time when I will have time to understand mmb2csub. |
||||
| PeteCotton Guru Joined: 13/08/2020 Location: CanadaPosts: 665 |
That's a very interesting read thanks! I learned a lot. |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 6168 |
Thanks Peter, That is useful, and I learned that a()=b() also works. Never knew that. Always used MATH ADD b(),0,a() - Despite the numbers for RP2040 would look inferior to RP2350, the comparisson would have been better when both would run the same clock speed. Yes, I am aware I can run the speed test myself at my clock frequency. - You did not mention the influence of audio (PWM/I2S/SPI) on the average speed when a- not using it, but it is configured in OPTIONS b- playing TONE/SOUND/WAV/FLAC/MP3(2350 only) This would make the report more complete. If you design game loops it is also nice to know how that speed reduction shows. i.e. 2ms blackout every 10ms, or 20ms every 100ms. But outside that, it has been very informative. Volhout Edited 2026-10-08 17:34 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |