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 : CMM2: V5.05.06RC19: Scotty more power
Page 1 of 4 | |||||
Author | Message | ||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8567 |
V5.05.06RC19 http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip This version has two small changes that have made an amazing difference. Thanks to the guys playing with the tetrahedron challenge we found out that processing a hex number was much faster than a decimal number - wtf . Investigating this revealed the problem and has resulted in a much bigger gain than was expected because it related not only to simple assignments e.g. a=123 but also things like a(1)=b and PIN(5)=1. Basically anytime a scalar value appeared in the program. The second change is to add yet another command which again can yield a huge benefit Consider the line a=a+1: In this simple example the interpreter has to search for "a" twice, search for the LET command, and then the + operator. To overcome this I've added the INC command INC var [,increment] If the optional increment is missed var is incremented by 1. If the increment is specified (and it can be another variable of course) then var is updated by the value of the increment. This command is available for integers and floats and any mix thereof. In addition it can be used for strings in which case the "increment" is mandatory and is appended to the first string INC string1$, string2$ is the same as "string1$ = string1$ + string2$" The difference the INC command makes can be extraordinary if used in a tight loop which may often be the case. The simple speed lines-per-second test code is: 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 'inc cnt next ' PRINT "Speed is"; INT((cnt * lines)/(TIMER /1000)); " lines per second." The results in successive releases have been as follows: V5.05.05 325826 V5.05.06RC13 358830 V5.05.06RC19 437480 'using cnt=cnt+1 V5.05.06RC19 540578 'using inc cnt Other benchmarks relative to V5.05.05 are as follows: Test V5.05.05 V5.05.06RC19 Measure Grainbench 15968 17916 Arbitrary simple benchmark zmim 1210 1866 Instructions per second Solar Eclipse 14.08 7.49 Time to complete complex calculation Speedtest 325826 540578 MMBasic Lines/second Benchmark 0.328 0.170 Simple benchmark with GOSUB and GOTO Wolf3D 14 21 Framerate per second Darkness 13 23 Framerate per second Bucky Ball 68 46.9 Time to calc and display new position (mSec) NB to thwill: Tom, I've modified zmim to use the INC command in lots of places to get the above result This version has been tested on every single program in the Welcome pack, Gauntlet, Wolf3D, FFight and many of my small test programs and so far is looking good. |
||||
Pilot352 Newbie Joined: 12/08/2020 Location: United StatesPosts: 34 |
Great idea. But what about a DEC command?? You know how we are... We always need more power! Edited 2020-11-15 02:48 by Pilot352 |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8567 |
What about using a negative increment |
||||
CircuitGizmos Guru Joined: 08/09/2011 Location: United StatesPosts: 1421 |
INC var, -1 ?? Edit: Simultaneous posting. Edited 2020-11-15 03:00 by CircuitGizmos Micromites and Maximites! - Beginning Maximite |
||||
CircuitGizmos Guru Joined: 08/09/2011 Location: United StatesPosts: 1421 |
I expect you'll hear others ask: "Can I have var++ ?" Edited 2020-11-15 03:03 by CircuitGizmos Micromites and Maximites! - Beginning Maximite |
||||
twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1133 |
Hi, how about to use INC var, -1? The slots for commands are limited. Regards Michael EDIT: I'm too slow! Edited 2020-11-15 03:11 by twofingers |
||||
LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 439 |
Again matherp, thank you for the improvements. I'll adapt the octahedron to the RC19. My current version is using hex numbers in all places. I'll compare the same source code using decimal x hex and post here the results. |
||||
William Leue Guru Joined: 03/07/2020 Location: United StatesPosts: 381 |
Good deal! I can't keep up with the blizzard of release candidates, but that is a Good Thing. -Bill |
||||
CircuitGizmos Guru Joined: 08/09/2011 Location: United StatesPosts: 1421 |
INC when it is also DEC and CAT will be confusing. I can't think of any token word that would be less confusing, however. Hopefully, it will be described clearly in the manual. Micromites and Maximites! - Beginning Maximite |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
More impressive work Peter and another thing to go on my TODO list. You do realise we're going to have to seriously consider sedating you so the rest of us can catch up. At least it is good for something Exhausted from just keeping up with the Release Candidates, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
Subject to Peter's will I believe he could use the CMM2's pre-process step to allow CAT, CONCAT, APPEND or something to be a synonym for INC without consuming a command slot (and pulling this trick elsewhere is how I understand he has magically manage to shoehorn in the recent additional commands). With sufficient will DEC could presumably be handled that way too, but he'd also need to negate the argument whilst handling the case that it could be a complex expression. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
PeteCotton Guru Joined: 13/08/2020 Location: CanadaPosts: 313 |
Once again THANK YOU! That is an incredible speed boost. |
||||
LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 439 |
My octahedron code was running in 1004ms using the RC18 with all numbers coded as hexadecimal and variables as float (because in the previous version float variables were fastest than integer). After upgrading to the RC19 these were the results: 1) Without changing the code: no time difference 2) Using decimal instead of hexadecimal (with all variables as float): 1045 ms 3) Using decimal but changing some variables to integer: 978ms I run the following test: option explicit option default float dim rf,l,vf=1.0 dim integer vi=1,ri print "starting test" timer=0 for l=1 to 1000000 rf=vi next l print "float <= vint : "+str$(timer) timer=0 for l=1 to 1000000 ri=vi next l print "int <= vint : "+str$(timer) timer=0 for l=1 to 1000000 rf=vf next l print "float <= vflt : "+str$(timer) timer=0 for l=1 to 1000000 ri=vf next l print "int <= vflt : "+str$(timer) timer=0 for l=1 to 1000000 rf=1 next l print "float <= int : "+str$(timer) timer=0 for l=1 to 1000000 ri=1 next l print "int <= int : "+str$(timer) timer=0 for l=1 to 1000000 rf=1.0 next l print "float <= float: "+str$(timer) timer=0 for l=1 to 1000000 ri=1.0 next l print "int <= float: "+str$(timer) timer=0 for l=1 to 1000000 rf=&H1 next l print "float <= hex : "+str$(timer) timer=0 for l=1 to 1000000 ri=&H1 next l print "int <= hex : "+str$(timer) These are the results: My conclusion is setting hex to float variables still a little fastest than decimal to float variables, but for decimal to integer variables the improvement is huge. |
||||
RetroJoe Senior Member Joined: 06/08/2020 Location: CanadaPosts: 290 |
“Incrementing” by a negative value feels a little quirky, but not much more so than a STEP -1 construct in a FOR loop. The cognitive difference is people understand that “steps” can go up or down, but that “increment” typically only means “up”. Three possible syntax alternatives to INC: 1) ACC (a, -1) would be more orthogonal and semantically accurate than INC. Yes, “accumulate” also generally means to “increase”, but a computer accumulator register, or a variable used as such, is expected to accumulate both positive and negative values 2) ASSIGN (a,-1). Same idea as above, with an implied addition operation. 3) Adopt the “a += -1” shorthand from C and Python. This would be the cleanest and most elegant approach, IMHO, assuming MMBasic can pre-process the += “add and assign” operator for acceleration. It’s not standard BASIC... but neither is “INC”. Cheers, Enjoy Every Sandwich / Joe P. |
||||
elk1984 Senior Member Joined: 11/07/2020 Location: United KingdomPosts: 227 |
Please, please, please release it! There's so many toys but I'm too frit to install betas and RCs We all know there's a 5.05.07 coming sometime. For my interest, what merits major, minor, revision in the versioning. I'd have thought the wholescale upgrade of varaible lookup and the performance that brings must be worth a "minor" increment? Edited 2020-11-15 04:49 by elk1984 |
||||
markboston36 Regular Member Joined: 27/10/2020 Location: United StatesPosts: 76 |
..............numbers make my eyes bleed. ill take your word its faster. |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1590 |
Please, please, please release it! Plus one. I'd love to have an up-to-date printed manual. For info this INC or += suggestion came up for MMBasic before and was rejected. I'm glad it finally made it. I'd love to know which (if any) of these improvements Peter has made will make it to MMBasic for the Original Maximites and the Micromites. Thank you Peter and Geoff. Bill Keep safe. Live long and prosper. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
Hi Peter, I'm having issues with RC19, here is an "easy" one for starters that I ran across whilst trying to reproduce the "real" problem: Colour Maximite 2 MMBasic Version 5.05.06RC19 Copyright 2011-2020 Geoff Graham Copyright 2016-2020 Peter Mather > list "bug.bas" #Include "bug2.inc" Sub foo() End Sub > list "bug2.inc" Sub foo() End Sub > run "bug.bas" Error in bug2.inc line 1: Duplicate name > ls Error in bug2.inc line 1: Duplicate name > edit Error in bug2.inc line 1: Duplicate name > Print "Hello World" Error in bug2.inc line 1: Duplicate name > new Error in bug2.inc line 1: Duplicate name > clear Error in bug2.inc line 1: Duplicate name > Print "Peter, I think this is broken!" Error in bug2.inc line 1: Duplicate name Best wishes, Tom Edited 2020-11-15 20:40 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8567 |
Not specific to RC19 - will fix |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
Thanks Peter. But I'm just warming up ... unfortunately RC19 has broken parts of my tool-chain which has made reducing the problem to a reproducable small example harder. Tom Edited 2020-11-16 01:23 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Page 1 of 4 |
Print this page |