Qbasicnews.com

Full Version: Speed of UDT's
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How is the speed of UDT's compared to straight variable's? Are they any slower?

I tend to like to group things together instead of

HP as integer
MP as integer

and so on I like to use this

TYPE playerinfo
hp as integer
mp as integer
end type

just wondering if there is a significant performance hit using UDT's they make saving games and such MUCH easier.
No real speed difference, it compiles to the same thing (well almost)


I can't think that thers any major or noticable speed difference..

I use UDTs mixed with "regular" non UDT arrays all the time, i cant say theres any difference...

Anonymous

i think the biggest speed difference would be reading/writing large amounts of variables to/from a file, if you even gonna do that =p

mostly just for structure, readability, etc

(i think)
They are exactly the same once the program is compiled: references to memory locations.
using CONSTants the compiler produces smaller and faster executables
An array of UDT's is slower than several arrays of simple variables.
This is what my experience says Big Grin

It happens in FB too (using indexes).

Perhaps it's a caché issue?

It's curious the opinions are so different.
It depends on how the compiler translates it...

I can imagine a UDT might require some more math, seeing as with ordinary arrays, yu just increase with array type to get the next one, which is usuallu 1, 2, or 4 bytes (meaning easy, fast math)

But with UDTs you can get for example 13 bytes...

Thats what the padding is for... faster and stuff...


But IMO, it's neglectable...

For extremely speed sensitive loops, use regular arrays...
the microsoft knowledge base says that the qbx can handle 2,100 constants

i would be a good idea to have a subforum where can be put all kind of records, velocities, differences of every detail of the quickbasics

that way we all will know what kind of codes have the best efficency and rapidness

everyone of us would put our own velocity records and compare them including tricks most of us do not know
If you need a faster program use a faster algorithm. Optimizing odd and random things like UDTs will not get a big speed increase. If your algo is bad your program will be slow no matter if you gain a cycle 'cause you use a constant instead of a number.
Was just a fleeting thought , I have been working on a game for a few weeks and im very picky about speed, Im even coding it on a slower computer just to get some perspective.

I dont know much (if anything) about the mechanics of interpreters/compilers so i was just wondering about this Smile
Pages: 1 2