6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 9:36 am

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Sat Jul 31, 2021 11:18 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
The recent thread about EhBASIC made me re-visit it and port the latest "P5C" version to my Ruby board. I'm not sure it will be of interest to anyone - mostly because it would only run on a Ruby board but if anyone wants the source with my changes them please let me know.

However I did use it to re-visit some old things - mostly benchmarking. I was curious to see if the "C" changes (for the 65C02) were actually improving it in terms of speed - and sadly, no. At least not for the Mandelbrot - and that's possibly not surprising as 99% of the code is doing floating point calculations and I didn't see much change from the original MS Basic to EhBASIC - however we know from the 65C02 version of BBC Basic that not only can we go much faster, we can go much faster and add an extra byte of precision too...

So room for improvement - but like most of these projects - does anyone have the time or inclination to do it?

The results:

EhBASIC: 79 seconds
CBM2 BASIC: 82.5 seconds
BBC Basic 4: 48.2 seconds.

(And just for "LoL"s, I wrote the same program in BCPL and it runs in 26 seconds)


Anyway, I put a little video together:

https://youtu.be/bwUecbPB7TI

Code:
............,,,,,,,,,,,,,,'''''''''''''''''''''''''',,,,,,,,,,,,,
...........,,,,,,,,,,,''''''''''''''''''''''''''''''''',,,,,,,,,,
..........,,,,,,,,,'''''''''''''''''''''''~~~~===~~~~''''',,,,,,,
.........,,,,,,,,'''''''''''''''''''''~~~~~~=+[&+==~~~~~''''',,,,
........,,,,,,,'''''''''''''''''''''~~~~~~~==+: ;+++~~~~~~''''',,
.......,,,,,,'''''''''''''''''''''~~~~~~~~===+:[ / [+~~~~~~''''''
......,,,,,,''''''''''''''''''''~~~~~~~~~===+:;/?o[:+==~~~~~'''''
......,,,,''''''''''''''''''''~~~~~~~~~====+:O/x  <;:+==~~~~~~'''
.....,,,,''''''''''''''''''''~~~~~~~~~===++:#      X/+====~~~~'''
.....,,,'''''''''''''''''''~~~~~~~~~==++++:;/X      [:++====~~~''
....,,,'''''''''''''''''''~~~~~~~~==+++:::;[/      X/;:+++++==~~'
....,,''''''''''''''''''~~~~~~~===+[<&x[[? <&x     o&//<;:::[[=~~
...,,'''''''''''''''''~~~~~~=====+:;    &O              /[</&/:=~
...,'''''''''''''''''~~~========++:;<                    x    :=~
..,,'''''''''''''''~~=========+++:;/<O                       ;+==
..,'''''''''''''~~~=========++++:< ##                      X<;:+=
..''''''''''~~~~==:/++++++++::::;/x                          [;:=
.,''''''~~~~~~===+:X[;:;; ;;::;;[                             o/=
.,''''~~~~~~~===++;<xXo<<X &<[[[/                             X:+
.'''~~~~~~~=====+::[&         <<&                             /:=
.'~~~~~~~~=====+::;/?          oO                              :=
.'~~~~~~~====++/;[/o                                          [+=
.~~~~~~=++++::;/???X                                         #:+=
.==++:/::+:;;[[o                                             :+==
                                                           &[:+==
.==++:/::+:;;[[o                                             :+==
.~~~~~~=++++::;/???X                                         #:+=
.'~~~~~~~====++/;[/o                                          [+=
.'~~~~~~~~=====+::;/?          oO                              :=
.'''~~~~~~~=====+::[&         <<&                             /:=
.,''''~~~~~~~===++;<xXo<<X &<[[[/                             X:+
.,''''''~~~~~~===+:X[;:;; ;;::;;[                             o/=
..''''''''''~~~~==:/++++++++::::;/x                          [;:=
..,'''''''''''''~~~=========++++:< ##                      X<;:+=
..,,'''''''''''''''~~=========+++:;/<O                       ;+==
...,'''''''''''''''''~~~========++:;<                    x    :=~
...,,'''''''''''''''''~~~~~~=====+:;    &O              /[</&/:=~
....,,''''''''''''''''''~~~~~~~===+[<&x[[? <&x     o&//<;:::[[=~~
....,,,'''''''''''''''''''~~~~~~~~==+++:::;[/      X/;:+++++==~~'
.....,,,'''''''''''''''''''~~~~~~~~~==++++:;/X      [:++====~~~''
.....,,,,''''''''''''''''''''~~~~~~~~~===++:#      X/+====~~~~'''
......,,,,''''''''''''''''''''~~~~~~~~~====+:O/x  <;:+==~~~~~~'''
......,,,,,,''''''''''''''''''''~~~~~~~~~===+:;/?o[:+==~~~~~'''''
.......,,,,,,'''''''''''''''''''''~~~~~~~~===+:[ / [+~~~~~~''''''
........,,,,,,,'''''''''''''''''''''~~~~~~~==+: ;+++~~~~~~''''',,
.........,,,,,,,,'''''''''''''''''''''~~~~~~=+[&+==~~~~~''''',,,,
..........,,,,,,,,,'''''''''''''''''''''''~~~~===~~~~''''',,,,,,,
...........,,,,,,,,,,,''''''''''''''''''''''''''''''''',,,,,,,,,,
............,,,,,,,,,,,,,,'''''''''''''''''''''''''',,,,,,,,,,,,,


Cheers,

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 12:59 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
Some good feedback...

The CMOS version has mainly resulted in a smaller code size overall. Page Zero usage has also been reduced with the change in the "LAB_IGBY" routine now being in ROM and using CMOS addressing. There's also been some code (and source formatting) cleanup, patches added, IRQ/NMI code removed (as it didn't really work) and some minimal performance improvements. However, the performance improvements are small but apparent when compared to the original code base.

Overall, I think this version is likely easier to get running on most systems with minimal change (than the original) as the Page Zero usage is both smaller and contiguous now, which is a shout-out to JG Harston who initially optimized the Page Zero defines.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 1:05 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Very interesting! I was a bit surprised at the performance advantage of BBC Basic 4, so I ran a somewhat abbreviated version of the program to compare with Basic 2 - the result being that Basic 4 is, in that case, very nearly 1.3x faster than Basic 2. Perhaps I should run the full version... OK, done that, 1.3x again.


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 1:42 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
floobydust wrote:
Some good feedback...

The CMOS version has mainly resulted in a smaller code size overall. Page Zero usage has also been reduced with the change in the "LAB_IGBY" routine now being in ROM and using CMOS addressing. There's also been some code (and source formatting) cleanup, patches added, IRQ/NMI code removed (as it didn't really work) and some minimal performance improvements. However, the performance improvements are small but apparent when compared to the original code base.

Overall, I think this version is likely easier to get running on most systems with minimal change (than the original) as the Page Zero usage is both smaller and contiguous now, which is a shout-out to JG Harston who initially optimized the Page Zero defines.


Wrangling ZP is on my to-do list for Applesoft - which I have running on Ruby, but there are enough clashes with RubyOS to stop the filing system working, so save/load is problematic. (Not to mention the graphics!)


Cheers,

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 1:52 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
BigEd wrote:
Very interesting! I was a bit surprised at the performance advantage of BBC Basic 4, so I ran a somewhat abbreviated version of the program to compare with Basic 2 - the result being that Basic 4 is, in that case, very nearly 1.3x faster than Basic 2. Perhaps I should run the full version... OK, done that, 1.3x again.


The 4 BBC Basic timings

  • BASIC [00] (C)1981 Acorn -- 62.6
  • BASIC [01] (C)1982 Acorn -- 62.48
  • BASIC [03] (C)1983 Acorn -- 62.52
  • BASIC [04] (C)1984 Acorn -- 48.24

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 3:19 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Remarkable! I think we know that Basic 4 is the first to make full use of the 'C02, and also that it was substantially revised for speed and accuracy. As you know, in all cases the floats are 5 bytes.


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 4:04 pm 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 352
There's a later version of BBC Basic 4 (version 4.32 copyright 1988) that might be worth trying as well.

This may well be faster still.

Dave


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 4:31 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
BigEd wrote:
Remarkable! I think we know that Basic 4 is the first to make full use of the 'C02, and also that it was substantially revised for speed and accuracy. As you know, in all cases the floats are 5 bytes.


Indeed - which makes it ever more remarkable in that both CBM2 Basic and EhBASIC have the smaller 4 byte floats.

Applesoft used the MS 5-byte float format, so I'll expect that to be slower when I get it going.

... And in checking some of the Applesoft stuff, I found this which may be of interest to some: https://www.callapple.org/programming/floating-point-arithmetic-in-applesoft-basic/

Cheers,

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 4:53 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Curiously, in the stardot thread "Why was BBC BASIC so fast?" there was some evidence (from other benchmarks) that the Beeb's 2MHz clock speed was the main advantage, despite various cleverness in the interpreter. And yet here, something about this comparison is showing a real difference.


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 7:44 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
(Oh, and thanks for the Call-A.P.P.L.E link - interesting reading!)


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 7:59 pm 
Offline

Joined: Wed Nov 11, 2020 10:42 pm
Posts: 104
Location: Kelowna Canada
Just to add more data points I have been using the version of Mandelbrot provided by Gordon and tried this on as many as I had access to for fun. Timing might be a little sketchy and the BBC versions (the fastest) used the built in timer as called in the program. Its apparent that BBC Basic is faster than EHbasic and on a par with Basic09. I'm not trying to start a war, these are just the results that I generated for machines at my disposal.
Sorry its a PDF but at least it is formatted better than what I could do inside the forum.


Attachments:
BasicComparisonSpeed.pdf [83.37 KiB]
Downloaded 186 times
Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 31, 2021 8:19 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
okwatts wrote:
Just to add more data points I have been using the version of Mandelbrot provided by Gordon and tried this on as many as I had access to for fun. Timing might be a little sketchy and the BBC versions (the fastest) used the built in timer as called in the program. Its apparent that BBC Basic is faster than EHbasic and on a par with Basic09. I'm not trying to start a war, these are just the results that I generated for machines at my disposal.
Sorry its a PDF but at least it is formatted better than what I could do inside the forum.


That's a good table of results, thanks!

Interesting to see it on some much faster systems - when I run it on my own BASIC (written in C runs under Linux) it takes about 0.3 seconds, however that's only if I don't print anything as printing takes it over a second due to the way my BASIC does screen handling, so it's hard to try to maintain a constant sense of "fairness" about it all...

I didn't know about Basic09 until now - looks like it was quite clever for the time too.

The time for the Sym-1 version is interesting - 1225 seconds on a 1Mhz system - divide that by 16 to scale-up to my 16Mhz system and it comes to 77 seconds which is not far from the 79 seconds I get here for EhBASIC - that's actually a good measure of confidence in it too.

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 26, 2024 3:10 pm 
Offline

Joined: Tue Feb 07, 2023 12:27 pm
Posts: 49
I ran the Mandelbrot test on my STM32h750 based 65816 simulator at 480 MHz and EhBASIC2.22. The test took about 4 min 50 sec, but the delay was mainly due to sending data to the terminal. I estimate that this corresponds to about 4 MHz of the 65816.
https://filmy.elektroda.pl/21_1729928129.mp4


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 26, 2024 4:45 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8509
Location: Midwestern USA
gregorio wrote:
I ran the Mandelbrot test on my STM32h750 based 65816 simulator at 480 MHz and EhBASIC2.22. The test took about 4 min 50 sec, but the delay was mainly due to sending data to the terminal. I estimate that this corresponds to about 4 MHz of the 65816.
https://filmy.elektroda.pl/21_1729928129.mp4

What happens if you time it without terminal I/O?  I’d think that would give you a reasonably-accurate idea of how well your code is running.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 27, 2024 12:21 pm 
Offline

Joined: Tue Feb 07, 2023 12:27 pm
Posts: 49
when I change the code lines:
Code:
460 Q$=MID$(C$, CC - SO, 1)
470 NEXT
480 NEXT
490 END

program is executed in similar time.

I noticed that there is a problem with EdBasic when deleting/edit program lines. The problem occurs in my simulator as well as in Kowalski simulator.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: