Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:41 28 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : [Picomite] Optimizing for speed

     Page 2 of 2    
Author Message
hhtg1968
Senior Member

Joined: 25/05/2023
Location: Germany
Posts: 123
Posted: 05:47pm 04 Jul 2023
Copy link to clipboard 
Print this post

speed optimization was/ is(?) my passion. in the 80´s i programmed (in assembler) several arcade games on z80 systems with 3.54 mhz. every tick is important for speed.

very often in interpreted systems the length of the names of variables has a meaning:  by using a compiler it is not importand for the speed in runtime. but often in an interpreter the length can low down the speed. i will test on picomite wether there is a difference in speed with the var "HowBigIsThisValueOnScreen" and "h". i do not know how mmbasic is programmed; perhaps geoffg or matherp can say something to the length of the names of vars or subs.

sometimes i asked me, wether it would be cool to have 8bit or 16bit integer vars.

by using "small" loops it can be better to repeat simply the order:

if you code:

for x=1 to 3:print "x":next

most of the time the cpu will handle the loop itself, not the code inside the loop...
if the code is not long (in the loop), it could be better to code a few orders without loop:

print"x":print"x":print"x".

a problem in the 80´s:
If you code a hires scroll in a memory with bit shifting commands you will get speed if you code 256 shift commands (with carry flag) instead of coding a loop.

in early times there are so called macro assemblers to help.

i will have time the next weeks to test the mmbasic speed optimization...
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 07:09pm 04 Jul 2023
Copy link to clipboard 
Print this post

Thank you all for these advices!

I will make a few changes in my code to see if I can get a few ms. Then, I will overclock the CPU.
Frédéric
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3150
Posted: 07:10pm 04 Jul 2023
Copy link to clipboard 
Print this post

Of course this: print"x":print"x":print"x"

does not give the same result as this: for x=1 to 3:print "x":next

But your point is well take--in some critical situations, unrolling a loop will help.

With MMBasic, it's been largely onward and upward with respect to speed (but not for the PicoMite, which has many other advantages, including availability).

Comparison between versions from this thread

               BM1     BM2    BM3      BM4     BM5     BM6     BM7     BM8
80's computers
ABC 800 single   0.9     1.8    6.0      5.9     6.3    11.6    19.6     2.9
ABC 800 double   1.2     2.2    10.0    10.6    11.0    17.8    26.4    14.4
IBM PC           1.5     5.2    12.1    12.6    13.6    23.5    37.4     3.5
Apple III        1.7     7.2    13.5    14.5    16.0    27.0    42.5     7.5
VIC-20           1.4     8.3    15.5    17.1    18.3    27.2    42.7     9.9
ZX81 "fastmode"  4.5     6.9    16.4    15.8    18.6    49.7    68.5    22.9

MMBasic
Maximite         0.016   0.144   0.196   0.205   0.354   0.512   0.721   0.310
Maximite w. #s   0.016   0.131   0.193   0.194   0.245   0.393   0.582   0.241
Maximite w/o #s  0.016   0.111   0.173   0.173   0.192   0.336   0.525   0.220
MicroMite 40MHz  0.028   0.18    0.285   0.289   0.644   0.892   1.346   0.376
MicroMite 48MHz  0.023   0.15    0.237   0.24    0.536   0.744   1.121   0.313
MM+ MX470 120MHz 0.013   0.082   0.135   0.135   0.265   0.380   0.597   0.174
MMX 198MHz       0.006   0.045   0.07    0.08    0.141   0.201   0.287   0.126
Picromite ZeroW  0.014   0.058   0.093   0.102   0.184   0.298   0.354   0.127
Armmite H7       0.003   0.023   0.038   0.042   0.067   0.098   0.146   0.065
ArmMite F4       0.011   0.079   0.14    0.149   0.249   0.354   0.528   0.257
MMBASIC DOS      0.0002  0.0017  0.0028  0.0028  0.0073  0.0092  0.0117  0.0058
CMM2             0.00176 0.0118  0.01903 0.01728 0.03611 0.05062 0.07582 0.02851
PicoMite         0.0166  0.1096  0.1800  0.1840  0.3325  0.4715  0.6688  0.3193
Linux            0.0000  0.0020  0.0040  0.0040  0.0080  0.0130  0.0190  0.0070

Other Recent Basics
ByPic MX170 40M  0.001   0.010   0.023   0.020   0.027   0.041   0.080   0.043
BBC_V Pi Zero    0.0001  0.0007  0.0016  0.0014  0.0015  0.0030  0.0030  0.0036
Annex RDS ESP32  0.032   0.223   0.384   0.338   0.463   0.714   1.224   0.631

C-Language
Arduino UNO      0.010   0.010   0.058   0.043   0.043   0.043   0.045   0.284
Arduino DUE      0.003   0.003   0.006   0.007   0.007   0.007   0.106   0.014
ESP32S           0.00007 0.00007 0.00030 0.00011 0.00016 0.00016 0.00016 0.02413

I think Peter published the numbers for MMB4W, but not in that thread.

~
Edited 2023-07-05 05:11 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 09:49am 19 Jul 2023
Copy link to clipboard 
Print this post

Hi,

I have another question about optimization: for audio reproduction, what does require less CPU: using a MPC4822 (SPI), or direct PWM (with low pass filter)?
Frédéric
 
cicciocb
Regular Member

Joined: 29/04/2014
Location: France
Posts: 70
Posted: 09:30pm 24 Jul 2023
Copy link to clipboard 
Print this post

Hi,
just for the precision, these are the results for Annex RDS

ESP32:

Benchmark 1
0.009

Benchmark 2
0.084

Benchmark 3
0.161

Benchmark 4
0.159

Benchmark 5
0.198

Benchmark 6
0.278

Benchmark 7
0.56

Benchmark 8
0.277


ESP32-S3:

Benchmark 1
0.008

Benchmark 2
0.065

Benchmark 3
0.124

Benchmark 4
0.119

Benchmark 5
0.149

Benchmark 6
0.218

Benchmark 7
0.413

Benchmark 8
0.211
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 09:43pm 24 Jul 2023
Copy link to clipboard 
Print this post

PWM is a bit less of a load on the CPU than driving the DAC, but the sound quality is inferior, especially at the higher frequencies. PWM also uses more components and more PCB area. :)
Edited 2023-07-25 07:44 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024