Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:36 02 May 2025 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 : BASIC Speed Benchmark Tests

     Page 8 of 8    
Author Message
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4815
Posted: 06:04am 10 Oct 2024
Copy link to clipboard 
Print this post

Wauw,

I once did a project in F84 (Forth for the PIC16F84).
It ended up being a real nice working product, and actually the development time was not bad (given that I did not have any knowledge about Forth when I started).

But, same as above, the code is hard to understand. I really have to take out my HP11C calculator, make a few calculations, to get back into RPN (Forth is RPN) and go from there.

Volhout
PicomiteVGA PETSCII ROBOTS
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1134
Posted: 07:28am 10 Oct 2024
Copy link to clipboard 
Print this post

  Volhout said  Wauw,

I once did a project in F84 (Forth for the PIC16F84).
It ended up being a real nice working product, and actually the development time was not bad (given that I did not have any knowledge about Forth when I started).

But, same as above, the code is hard to understand. I really have to take out my HP11C calculator, make a few calculations, to get back into RPN (Forth is RPN) and go from there.

Volhout


Often referred to as a write-only language  
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 549
Posted: 01:24pm 26 Apr 2025
Copy link to clipboard 
Print this post

I have translated the benchmark into a little f77 and run it, but the pico seems disappointingly slow,  especially so with double precision.

Looking at the Basic benchmark parts 7 and 8

Print "Benchmark 7"
Timer = 0
j = 0
dim ray2(5)
BM7:
j = j+1
m = j/2*3+4-5
Gosub 4000
For q = 1 TO 5
ray2(q) = m
Next q
If j < 1000 GoTo BM7
Print Timer / 1000
Print " "

Print "Benchmark 8"
Timer = 0
j = 0
BM8:
j = j+1
m = j^2
blog = LOG(j)
csin = SIN(j)
If j < 1000 GoTo BM8
Print Timer / 1000



I guess  j/2*3+4-5  is using single prec floating point, but are LOG(j)
and SIN(j) assuming input j is an integer ? Some math routines are much faster
using integers as input, so that may be a factor.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3988
Posted: 02:32pm 26 Apr 2025
Copy link to clipboard 
Print this post

  zeitfest said  I guess  j/2*3+4-5  is using single prec floating point,

Looks like double in Picomite MMBasic.

  zeitfest said   but are LOG(j)
and SIN(j) assuming input j is an integer ?

Not by the looks of the source code.

It gets linked with the SDK's C library routines and I don't know whether they do some sort of tests for doubles which happen to be integers.  (You could find out with some fairly simple code and timing loops I suppose.)

John
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1134
Posted: 02:38pm 26 Apr 2025
Copy link to clipboard 
Print this post

  zeitfest said  
Some math routines are much faster
using integers as input, so that may be a factor.


I was recently testing this, expecting integers to be faster but I found it not to be the case.
Can you give an example, please?

 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 549
Posted: 11:57pm 26 Apr 2025
Copy link to clipboard 
Print this post

I think many systems had a LOG (x) function where if x is an integer, some math tricks were used to simplify and speed it up, I will try to dig up some detail.

BTW This is the benchmark (with the lines and structure kept as original as practical including go to-s) as approximated using f77ish interpreter. [I added a MILLI function.] The output times are in milliseconds. Running on a standard pico with  sdcard and i2c keypad and lcd interface running. It is a bit slow but it has debugging etc stuff to clean up yet.

Running

     PROGRAM benchmarkdev
     INTEGER*4 j, a, q, ray(5)
     INTEGER*4 now, last, span
     DOUBLE b, c, d
     d = 1.123
C   Benchmark 1
     last = MILLI 1
     DO 10 j = 1, 1000
  10 CONTINUE
     now = MILLI 1
     span = now - last
     PRINT *, "Benchmark 1   ", span
C   Benchmark 2
     last = MILLI 1
     j = 0
  20 j = j + 1
     IF ( j < 1000 ) GO TO 20
     now = MILLI 1
     span = now - last
     PRINT "Benchmark 2   ", span
C   Benchmark 3
     last = MILLI 1
     j = 0
  30 j = j + 1
     a = j/j*j+j-j
     IF ( j < 1000 ) GO TO 30
     now = MILLI 1
     span = now - last
     PRINT "Benchmark 3   ", span
C   Benchmark 4
     last = MILLI 1
     j = 0
  40 j = j + 1
     a = j/2*3+4-5
     IF ( j < 1000 ) GO TO 40
     now = MILLI 1
     span = now - last
     PRINT "Benchmark 4   ", span
C   Benchmark 5
     last = MILLI 1
     j = 0
  50 j = j + 1
     a = j/2*3+4-5
     CALL thesub ( )
     IF ( j < 1000 ) GO TO 50
     now = MILLI 1
     span = now - last
     PRINT "Benchmark 5   ", span
C   Benchmark 6
     last = MILLI 1
     j = 0
  60 j = j + 1
     a = j/2*3+4-5
     CALL thesub ( )
     DO 65 q = 1, 5
  65 CONTINUE
     IF ( j < 1000 ) GO TO 60
     now = MILLI 1
     span = now - last
     PRINT "Benchmark 6   ", span
C   Benchmark 7
     last = MILLI 1
     j = 0
  70 j = j + 1
     a = j/2*3+4-5
     CALL thesub ( )
     DO 75 q = 1, 5
     ray(q) = a
  75 CONTINUE
     IF ( j < 1000 ) GO TO 70
     now = MILLI 1
     span = now - last
     PRINT "Benchmark 7   ", span
C   Benchmark 8
     last = MILLI 1
     j = 0
  80 j = j + 1
     a = j ** 2
     b = LOG (d)
     c = SIN (d)
     IF ( j < 1000 ) GO TO 80
     now = MILLI 1
     span = now - last
     PRINT "Benchmark 8   ", span
     END
C
C
     SUBROUTINE thesub ( )
     RETURN
     END
\

Benchmark 1   24
Benchmark 2   214
Benchmark 3   373
Benchmark 4   374
Benchmark 5   455
Benchmark 6   680
Benchmark 7   1111
Benchmark 8   610

OK

>
 
     Page 8 of 8    
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025