Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Particles and variable as

Author
Message
ICERGB
23
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Canada
Posted: 9th Nov 2003 09:58 Edited at: 9th Nov 2003 10:01
I will give you all the code to my wonderful(I think it is) particle program... (please leave my name as original creator intact and give me kudos) if someone; promises to make it into a fast variable IanM style program;
I will give you all the code, bitmaps and the x file.

All you have to do is make it into types and make sure it is the fastest!

I need assurance!!!!

IanM says
Quote: "+ Code Snippet
dim PosX(10)
dim PosY(10)
dim Speed(10)
dim Direction(10)
PosX(1)=1
PosY(1)=1
Speed(1)=4
Direction(1)=10


Is less efficient than this code:

+ Code Snippet
type Info_t
Speed
Direction
X
Y
endtype
dim Info(10) as Info_t
Info(1).Speed=4
Info(1).Direction=10Info(1).X=1
Info(1).Y=1
"
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 9th Nov 2003 13:55
I'm no expert but UDTs do seem to be the way to go. Maybe it could save memory, by only storing one array?

"The trouble with the French is that they have no word for 'entreprenuer'" - Pres. George W Bush

Please visit http://www.davidtattersall.me.uk
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Nov 2003 15:46
Oooo, I'm a programming style now!

Yes, it does save memory - the overhead of each array is approx 56 bytes, plus 4 bytes per array entry

But the reason I posted that was to highlight the speed inprovements. If the data is grouped together like that then accessing the first item in the type will cause the processors pre-fetch hardware to bring some or all of the following data into the cache before it is asked for, making access of that data faster.

Login to post a reply

Server time is: 2026-07-26 17:34:19
Your offset time is: 2026-07-26 17:34:19