Apple Silicon is insanely fast, except...

Discussions related specifically to the Windows, Linux (86), Mac OS-X and Raspberry Pi editions of BB4W and BBCSDL
Richard Russell
Posts: 714
Joined: Tue 18 Jun 2024, 09:32

Apple Silicon is insanely fast, except...

Post by Richard Russell »

... for function calls, which are exceptionally slow! I can only surmise that the reason for this is that the current CPU 'context' - which has to be saved and restored around a function call - is particularly large. In speed-critical code, if you can use a PROC with a RETURNed parameter instead of an FN you should.

 BBC BASIC for MacOS version 1.44a                     Average:      44 ns

 Colon:                       2 ns       A%=B%<<C%:                  49 ns
 Dispatch (ENDCASE):          5 ns       A%=B%>>C%:                  48 ns
 Dispatch (ENDIF):            4 ns       A%=B%>>>C%:                 49 ns
 NEXT (integer):              8 ns       A%%=B%%:                    40 ns
 NEXT (default real):         8 ns       A%%=B%%+C%%:                61 ns
 NEXT (64-bit real):         10 ns       A%%=B%%-C%%:                61 ns
 NEXT N%:                    12 ns       A%%=B%%*C%%:                60 ns
 NEXT n%:                    17 ns       A%%=B%%DIVC%%:              60 ns
 NEXT N:                     17 ns       A%%=B%%/C%%:                61 ns
 NEXT N#:                    17 ns       A%%=B%%^3:                  68 ns
 REPEATUNTILTRUE:            20 ns       A%%=B%%<<C%%:               66 ns
 WHILEFALSE:ENDWHILE:        19 ns       A%%=B%%>>C%%:               66 ns
 A%=FALSE:                   23 ns       A%%=B%%>>>C%%:              66 ns
 A%=0:                       26 ns       A=B+PI:                     50 ns
 A=PI:                       28 ns       A=B-PI:                     50 ns
 ANTIDISESTABLISHMENT=PI:    35 ns       A=B*PI:                     49 ns
 A=(PI):                     43 ns       A=B/PI:                     49 ns
 A%=1234567890:              34 ns       A=B^3:                      73 ns
 A%=&499602D2:               27 ns       A=B^PI:                     52 ns
 A=1.23456789E38:            50 ns       A=SINB:                     46 ns
 A%=B%:                      29 ns       A=TANB:                     46 ns
 A=B:                        37 ns       A=LOGB:                     50 ns
 ANTI=ANTI:                  40 ns       A=EXPB:                     46 ns
 A%=B%+C%:                   44 ns       A=SQRB:                     44 ns
 A%=B%-C%:                   45 ns       A=ATNB:                     48 ns
 A%=B%*C%:                   42 ns       A=ABSB:                     42 ns
 A%=B%DIVC%:                 43 ns       A=INTB:                     43 ns
 A%=B%/C%:                   44 ns       PROC1:                      16 ns
 A%=C%^D%:                   64 ns       A%=FN1:                    331 ns