LIFE GAME : How to optimise/speed up ? - Printable Version +- Small Basic Forum (https://litdev.uk/mybb) +-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1) +--- Forum: Standard Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=2) +--- Thread: LIFE GAME : How to optimise/speed up ? (/showthread.php?tid=95) |
LIFE GAME : How to optimise/speed up ? - Elzaimer - 06-27-2024 Hello, it's me again I try to improve my level, so I began another SB project : a life game (NVCV425.000) I would like to know how to make it run faster, as with big grids it becomes very slow. For exemple, is there a faster way to display the living cells than using GraphicsWindow.FillRectangle ? My only idea at this moment to make it a little faster is to merge these 2 Subs (because they can be done in the same loop) : Sub AffichageTableau ' displays current Gen grid Sub CreationTableau_NextGen ' create nextGen grid If you have any idea... RE: LIFE GAME : How to optimise/speed up ? - z-s - 06-27-2024 Use LDFastshapes RE: LIFE GAME : How to optimise/speed up ? - litdev - 06-27-2024 Hi again, The main reason is that Small Basic arrays are slow and 2D array can be very slow - this was an internal design decision that arises from SB having no types (int, float string etc). Not so much you can do about it unless you use an extension as ZS suggests. I have no idea if you do or not, or want to consider this. Anyway I did a little test to show: Code: size = 100 On my PC (which is quite high spec) I get times of around 150 ms for each of the 2 passes. If I code the same using a LitDev extension method LDFastArray as below, I get timings of around 8 ms for each (this is actually still not very fast due to overheads using function calls and underlying SB data types, but better). Code: T1 = Clock.ElapsedMilliseconds There are other faster array tpes LDList (for 1D arrays not indexed by integer with improved sort capabilities) or LDArray (fastest for 1D arrays with a pre-defined size). If you are interested in these instruction for using LitDev extension can be found at https://litdev.uk and we can help futher with this. As ZS says there may be other optimisations, but I expect the arrays are the main offenders here. RE: LIFE GAME : How to optimise/speed up ? - Elzaimer - 06-27-2024 Hello, Thank you for your Answers. I installed SB-Prime (an advice from AB) and installed LitDed from the advanced menu. When clicking on RUN SB tels me that it is impossible beacause of a virus or malware see on this link : https://e.pcloud.link/publink/show?code=XZmnETZihN6whdexTf2gtMAvPhOk5nAJBy7 RE: LIFE GAME : How to optimise/speed up ? - litdev - 06-27-2024 Yeh, I know I get that too. I don't know what specifically it is, but there is loads of stuff in the LitDev.dll including for example the networking server stuff AB is using or other things that generic antivirus probably don't like. I can say it is safe if you download directly from my site (e.g. using SB-Prime from my site) and the code is open source on GitHub. What I do is using Windows Security->Virus & threat protection->Exclusions, then add an exclusion for the folder where I store all SmallBasic files (A sub folder of Documents). I then save any SB file I want to run, if I download the file I check it first, uncomment File commands as necessary, being sure about what it is doing. Some-one could write a program to delete stuff! I don't run Small Basic programs without saving first - if you don't save then they run in %temp%, over time clogging it up as SB doesn't clean up after itself. Also I wouldn't put an anti-virus exclusion for %temp% folder. RE: LIFE GAME : How to optimise/speed up ? - z-s - 06-29-2024 But I have seen in temp folder the program are of zero kb sized. Elzaimer you could also use extension manager in SB Prime or manual download extension manager from https://litdev.uk maybe it could work. RE: LIFE GAME : How to optimise/speed up ? - litdev - 06-29-2024 https://www.virustotal.com is a good place to test a dll for false positive virus, there are probably other similar sites. |