![]() |
Forum Index : Microcontroller and PC projects : CMM2: 270.000 lines of code per second, question
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
Decoy Senior Member ![]() Joined: 02/08/2019 Location: DenmarkPosts: 109 |
Hi guys This might be a silly question. I understand that the CMM2 is able to do 270000 lines of MMBasic per second. I need to reference this to something - as an example, how many lines could a C64 pull off? I know that a line isn't just a line, and that the numbers are dependent on what the intructions on the line is. Thanks, Nicholas |
||||
Poppy![]() Guru ![]() Joined: 25/07/2019 Location: GermanyPosts: 486 |
![]() https://www.youtube.com/watch?v=IA7REQxohV4 This Guy apparently just took it from here. And we need to know how Geoff measured it practically, to have a standard-code for an objective benchmark! Just because! ![]() ![]() | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10055 |
|
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4249 |
I suspect it is 100s-1000s of times faster than C64 BASIC. My specific experience with Z-MIM is that the CMM2 is probably interpreting BASIC at about 50-75% the speed of native 6502 machine code on the C64. HOWEVER that is just for the basic data-handling and conditional statements. If you are doing something for which the CMM2 BASIC dialect provides built-in support, e.g. graphics or various computationally intensive maths functions then it is O(100) times faster (if not more) than 6502 machine code. Regards, Tom Edited 2020-07-17 01:33 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10055 |
If you download the latest version http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip and make a tiny change to the benchmark ' speed test ' will test and report the speed of MMBasic ' dim integer i,cnt SETPIN 3,2 : SETPIN 5, 8 lines = 5 loops = 1000000 TIMER = 0 ' ' start of the timed section (5 lines) FOR i = 1 TO loops inp = PIN(3) PIN(5) = inp cnt = cnt + 1 NEXT ' PRINT "Speed is"; INT((loops * lines)/(TIMER /1000)); " lines per second." You can now get 282000 lines per second ![]() |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10055 |
Coming in RC4 ![]() |
||||
abraxas Regular Member ![]() Joined: 16/06/2020 Location: CanadaPosts: 99 |
Pete, what changes are you making in the release to optimize the interpreter? What expressions are going to see the most improvements? |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
Once mine arrives I plan to make a series of simple benchmarks to do comparisons between the CMM2, My C128 running in both 40 and 80 column modes (using BASIC 7 in 40 column, Basic 8 on the 80 column mode), and the C64 using Simons' Basic (to get the graphics commands). I'm planning to do comparisons on: Bubble Sort of an array of 1000 random numbers (performed 10 times) Calculating Pi to 1000 digits (using a relatively slow method) 2x2 matrix fill of 100x100 elements (tests looping speeds with nested loops) Drawing colored random lines Drawing unfilled + filled random rectangles Drawing unfilled + filles ovals Any other simple tests you guys can think of you'd like me to try? (something that doesn't require me to do stuff in Assembly on the Commodore because I have NO idea on that stuff...) Edited 2020-07-17 07:41 by mkopack73 |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2398 |
here is a rather classic speed test: Print "Sieve of Eratosthenes Speed Test" Start = Timer 10 W=500:Dim F(W):P=1:A=3 20 F(P)=A:P=P+1:If P>W Then GoTo DONE 30 A=A+2:X=1 40 S=A/F(X):If S=Int(S) Then 30 50 X=X+1:If X<P And F(X)*F(X)<=A Then 40 60 GoTo 20 DONE: Elapsed = (Timer-Start)/1000 Print Elapsed " seconds" I = 0 ' statement counter J = 0 ' line counter Erase F 110 I=I+4: J=J+1: W=500:Dim F(W):P=1:A=3 120 I=I+3: J=J+1: F(P)=A:P=P+1:If P>W Then GoTo FINI 130 I=I+2: J=J+1: A=A+2:X=1 Print ,P Chr$(13); 140 I=I+2: J=J+1: S=A/F(X):If S=Int(S) Then I=I+1: GoTo 130 150 I=I+2: J=J+1: X=X+1:If X<P And F(X)*F(X)<=A Then I=I+1: GoTo 140 160 I=I+1: J=J+1: GoTo 120 FINI: Print I " statements" Print J " lines" Print I / Elapsed " statements per second" Print J / Elapsed " lines per second" > > > run Sieve of Eratosthenes Speed Test 5.403 seconds 48122 statements 19747 lines 8906.53 statements per second 3654.82 lines per second with a number of results for many 80's systems here: http://www.retroprogramming.com/2010/01/8-bit-home-computer-benchmarks.html and a compiled list: How Fast Were Those Late 1970s Home Computers? 8-Bit Home Computer Benchmarks computer model clock CPU time ============== ===== === ==== TRS 80 model I with Level II Basic 1.77 MHz Z80 421s Sinclair ZX Spectrum +3 3.55 MHz Z80A 388s Tandy 102 2.40 MHz 80C85 367s Atari 130XE (Atari BASIC Rev. C) 1.79 MHz 6502C 338s Atari 800XL 1.80 MHz 6502 316s Tandy 64K CoCo 2 0.90 MHz 6809E 271s Commodore Plus/4 1.80 MHz 8501 267s Sony F1XV MSX2+ (MSX Microsoft BASIC 3.0) 3.58 MHz Z80A 260s Commodore C64 1.00 MHz 6510 254s Commodore VIC-20 (Microsoft BASIC 2a) 1.00 MHz 6502 234s TRS-80 Micro Colour Computer (MC-10) 0.90 MHz 6803 220s Apple IIe Enhanced (Applesoft II) 1.00 MHz 6502 211s Sharp MZ-731 4.00 MHz Z80A 182s Commodore 128 2.00 MHz 8502 152s Tandy 64K CoCo 3 1.79 MHz 809E 147s Amstrad CPC464 4.00 MHz Z80A 140s Acorn Electron 2.00 MHz 6502 138s BBC Model B (BBC BASIC 2) 2.00 MHz 6502 101s BBC Master (BBC BASIC 4) 2.00 MHz 65SC12 76s (the below list compiled June 2017) Micromite MX150 40 MHz mips M4K 6.86s Micromite MX170 (Mk II) 40 MHz mips M4K 5.31s Micromite MX470 (plus) 100 MHz mips M4K 2.96s Micromite MZ2048 (extreme) 200 MHz mips M 1.12s MMbasic on RPi Zero (JG) ARMv6 0.89s MMbasic on RPi B+ (DH) ARMv6 0.67s MMbasic on RPi Zero W (PM) ARMv6 0.63s MMbasic on RPi 3 (DH) ARMv8 0.22s MMbasic on RPi 3 (PM) ARMv8 0.19s MMbasic for WIN32 2400 MHz i7 0.06s from this thread: https://www.thebackshed.com/forum/ViewTopic.php?TID=9686 cheers, rob :-) |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1121 |
That speed test is quite the bit of code but it is not the Sieve of Eratosthenes. ================ It's interesting, I find I am very out of tune with 'classic' BASIC, with line numbers and GOTOs. Perhaps I have largely purged the spaghetti code mindset. So I had some trouble understanding what that snippet from line 20 to line 60 was actually doing. My rewrite in structured form looks like the following, although I cheat a bit and use "exit loop" statements. (Curiously, my rewrite is slightly faster than the original. Completely irrelevant for a performance test, but curious none the less.) T3 = Timer p = 1 ' position in array to store next prime a = 3 ' number to be evaluated for primeness F(p) = a ' 1st one is chosen as prime p = p + 1 ' advance to next position do a = a + 2 ' next candidate prime x = 1 ' start with 1st prime do s = a / F(x) ' test for division with no remainder if s = int(s) then exit do ' divides evenly so this one isn't prime x = x + 1 ' advance to next prime with which to test candidate if x > p or F(x) * F(x) > a then ' stop testing after sqr(a) F(p) = a ' found a new prime so save it p = p + 1 ' bump index exit do ' time to start testing next prime candidate end if loop loop until p > 500 T4 = Timer Visit Vegipete's *Mite Library for cool programs. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10055 |
![]() |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
I feel your pain... Last night I sat down at my C128D and tried to write a little simple program that would generate an array of random numbers, then do a simple bubble sort on them, timing the run, and then repeat it 10 times and avg the time results.... It was SOOOOOOO painful going back to old style Commodore BASIC, no while/Wend or repeat/until, etc., the old style editor (there was a time when I would have taken the C64 screen editor over VI in a heartbeat - not anymore!) the "everything in uppercase" and huge font... Needless to say it took me about 2 hours to get something that should have been very simple working the way I wanted it to. THANK GOD CMM2 and MMBasic are modern and reasonable... |
||||
GregZone Senior Member ![]() Joined: 22/05/2020 Location: New ZealandPosts: 114 |
Hmm... I'm using lastest RC5 and without the DIM line I was ~242000 lines/sec, after adding the pre-declare i,cnt variables the speed only went to ~244000 lines/sec. How did you achieve 282000 with the same code? Ahh.. actually, I'm guessing 480Mhz vs 400Mhz STM32? (I've a 400Mhz chip). |
||||
KeepIS![]() Guru ![]() Joined: 13/10/2014 Location: AustraliaPosts: 1822 |
That is where it shows, I'm still running an older version and your code does 277760 @ 480 MHz. NANO Inverter: Full download - Only Hex Ver 8.1Ks |
||||
KeepIS![]() Guru ![]() Joined: 13/10/2014 Location: AustraliaPosts: 1822 |
Speed 285304 lines per second with MMBasic Version 5.05.04RC5. NANO Inverter: Full download - Only Hex Ver 8.1Ks |
||||
abraxas Regular Member ![]() Joined: 16/06/2020 Location: CanadaPosts: 99 |
Yeah, I have two Waveshare boards and it mirrors my own experience that the 480 MHz version is about 10-15% faster. Not the 20% one might instinctively deduce. The RAM interface is probably limiting the speed somewhat so a faster CPU can only accomplish so much. |
||||
KeepIS![]() Guru ![]() Joined: 13/10/2014 Location: AustraliaPosts: 1822 |
Similar to the earlier ARMH7 boards that we use running MMbasic, I have one running a big automated CNC type of woodwork routing machine. They started out as 400MHz proto boards that could be overclocked, then a 480MHZ release which could also be overclocked, but in real world programs the difference was not really noticeable, it just made these sort of Speed tests look better. Mike. NANO Inverter: Full download - Only Hex Ver 8.1Ks |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
Just to give some comparison... Simple BASIC program that generates 20 random integers then performs a bubble sort on them, repeated 10 times to get an average run time... On a C128 it took 3.5 sec on average (FAST mode) The cmm2 does it in 10ms!! LOL |
||||
berighteous Senior Member ![]() Joined: 18/07/2020 Location: United StatesPosts: 110 |
Does the CMM2 processor have hardware math? The horrible soul crushing experience with AppleSoft basic is that 6502 had no math above addition and subtraction, so doing something like this plot ![]() takes several HOURS to draw. Here's the applesoft code for this: 10 GOTO 40 20 XE = - X * S1 + Y * C1 : YE = -X * C1 * C2 - Y* S1 * C2 + Z * S2 : ZE = - X * S2 * C1 - Y *S2 * S1 + Z * C2 + RHO 30 SX = D * XE / Z E + CX : SY = CY - D * YE / Z E :RETURN 40 RHO = 30 : D = 350 : THETA = .1 : PHI = 1 : CX =140 : CY = 96 : S1 = SIN (THETA) : S2 = SIN(PHI) : C1 = COS (THETA) : C2 = COS (PHI) 50 DEF FN Z(X) = COS (.1 * (X * X + Y * Y)) 60 HGR2 : HCOLOR= 3 70 FOR X = -20 TO 20 STEP .3 80 FL = 0 90 FOR Y = - 20 TO 20 STEP .07 100 Z = FN Z(X): GOSUB 20 110 IF SX < 0 OR SX > 279 OR SY < 0 OR SY > 191 THEN FL = 0 : GOTO 140 120 IF FL = 0 THEN FL = 1 : HPLOT SX,SY 130 HCOLOR=3:HPLOT SX,SY:HCOLOR=0:HPLOT SX,SY+1 TO SX,191 140 NEXT Y,X 150 PRINT CHR$(7):GET Q$:TEXT Even in AppleWin on full speed (like 100x apple native) it took a few minutes to do. |
||||
abraxas Regular Member ![]() Joined: 16/06/2020 Location: CanadaPosts: 99 |
CMM2 definitely has hardware for floating point calculations. Whether the implementation of trig functions in MMBasic is speedy I don't know. Just port and test it. However, with the amount of RAM that CMM2 gives you it's trivial to optimize this by precalculating and storing SIN/COS outputs for a quarter of the circle to the accuracy that is required and then the cost of trig functions will be that of a lookup in an array. You can make this run on a CMM2 in seconds. Maybe faster. |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |