![]() |
Forum Index : Microcontroller and PC projects : BASIC Speed Benchmark Tests
![]() ![]() |
|||||
Author | Message | ||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4815 |
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 KingdomPosts: 1134 |
Often referred to as a write-only language ![]() |
||||
zeitfest Guru ![]() Joined: 31/07/2019 Location: AustraliaPosts: 549 |
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 KingdomPosts: 3988 |
Looks like double in Picomite MMBasic. 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 KingdomPosts: 1134 |
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: AustraliaPosts: 549 |
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 > |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |