![]() |
Size Variables - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Size Variables (/showthread.php?tid=746) |
Size Variables - Bakekitsune - 15-02-2007 I will start off with a question... How many of you believe that you are going to have more than 32,000 players on one server. 1. Change all "byval index as long" to "index as integer" which should half the memory consumption for all that. 2. Change lcase(parse(0)) = " to case 3. In type recs or even anywhere unless you are going to have more than 32,000 of something change from long to integer which will have the amount of memory it takes up. 4. Change all booleans to byte and use 0 and 1 5. Even better if you use the bitfield system (just search it) *props 6. If you are always going to get a value between 255 and 0 then change longs or integers to byte. that should decrease that memory consumption by down to 1/8th 7. Don't use fixed length strings e.g "* MAX_LENGTH" just remove it you dont need it. if you want a max character property change that in the textbox properties. 8. if you use exit sub anywhere its easier just to use select case. I no theres more but i forget lol ![]() - William - 15-02-2007 Moved to Knowledge base. Quote:1. Change all "byval index as long" to "index as integer" which should half the memory consumption for all that.Change it to Byte instead. Quote:2. Change lcase(parse(0)) = "It has proven that no speed change occur. Quote:3. In type recs or even anywhere unless you are going to have more than 32,000 of something change from long to integer which will have the amount of memory it takes up.Nothing in MS requires anything to be above 32000. So not sure if that is a good idea. Quote:4. Change all booleans to byte and use 0 and 1Yes, thats good. There are already a constant for that I think.. YES and NO? Quote:5. Even better if you use the bitfield system (just search it) *propsHum? Quote:6. If you are always going to get a value between 255 and 0 then change longs or integers to byte. that should decrease that memory consumption by down to 1/8thIsn't the difference between byte and long 2bytes or something? Code: 7. Don't use fixed length strings e.g "* MAX_LENGTH" just remove it you dont need it. if you want a max character property change that in the textbox properties. Quote:8. if you use exit sub anywhere its easier just to use select case.hum? - Spodi - 15-02-2007 These are all not bad ideas, but you have to think on a wider scope. For 1, yes, you save 3 bytes if you convert it to a byte for every player on. Overall, that will save you, what? 150 bytes on a decently populated server (50 people on)? Its not bad to do this - in fact, its very good practice, but unless it is very critical (such as a loop called 100 times a second, or an array with over 1000 elements), you can spend months doing all little kinds of optimizations and end up with no noticeable difference. 8. Not really - each has their own use. Select case works only if comparing one variable. - William - 15-02-2007 1byte = nothing 1000 byte = 1kb 1000 kb = 1mb You see the point ![]() - Obsidian - 15-02-2007 All of the things mentioned have been mentioned before pretty much... and/or are common sense to most people (i would hope)... in all honesty i really don't think it matters too much anymore how much you try to optimize mirage. Sooner or later... about 90% of the way the server manages stuff is going to have to be rewritten... [Edit] And just to point it out... because that's how i roll... 8 Bits = 1 Byte 1024 Bytes = 1 KB... it's not 1000 like most people think... - William - 15-02-2007 Ahh.. thats why all computer has 128RAM... 1024RAM etc ![]() - Spodi - 15-02-2007 It actually depends on what you are using for the measurement. The golden rule of 1024s is technically correct, but I think hosting companies often round down and call it 1000byte = 1kb, etc. I have seen in done in other cases, too. Its not that they are trying to scam you out of your money, its just the way they do it (probably started for saving money, though :wink: ). - Bakekitsune - 16-02-2007 Dear william i will answer all you questions... plus more Quote:Change it to Byte instead Seeing as byte only goes up to 255 that would mean you could have only up to 255 players... hence integer which goes up to around 32000 Quote:It has proven that no speed change occur. In a very large procedure like "handledata" it does make a difference and you can also save alot of space (text wise) because you can remove "if" "lcase parse" "then" and "exit sub" Quote:Nothing in MS requires anything to be above 32000. So not sure if that is a good idea thats my point change all longs to integer lol Quote:Hum? Bitfield in mirage was devised by someone i think it was dave not sure, which fits 8 booleans in a byte. Quote:Isn't the difference between byte and long 2bytes or something? No in vb6, byte = 1 long = 8 Quote:If you don't make a string fixed length, it uses 20 bytes + the string length MORE memory. Keep all the strings that you can fixed length. Yes you would be right if everyone were to fill in all the spaces but... Fixed-length strings are generally slower than conventional strings, because all VB string functions and operators only recognize conventional strings, thus all fixed-length strings must be transparently converted to and from conventional strings. - William - 16-02-2007 Not sure how long you have been in the community, and I don't think anybody know how many players a optimized MSE can carry. But I doubt it will go above 255 at the same time. - Bakekitsune - 16-02-2007 ive been here since i was 12-13 so 4-5 years ago btw no offense (this is in no means offensive in anyway) but there is already a game called key2heaven (just letting you know ![]() perhaps unless you have a friend with t3 and im getting ADSL2 anyway... Im also devising a new mix client/server system which could handle unlimited players (with the expense of easy hacking if found out. ![]() - William - 16-02-2007 I didn't know there was such a game. Would you like to link me? Edit: Just searched, found a game name Key of Heaven. =/ - Spodi - 16-02-2007 Variable and fixed length both have their times and uses. You shouldn't just use one because it is better or whatever - if you are even doing string-intensive operations in a 2d ORPG (or most any online game non-text based) you have seriously screwed up already. Using a variable-length string is probably going to be faster then using Trim$(CosntantString). If you know a string will be X characters long, and never anything else, then go ahead and use that. - Bakekitsune - 17-02-2007 lol im confused... how can a 2byte datatype be slower than a 4byte data type thx anyway thats awesome coz all of my datatypes are byte so i just have to click all advanced options, what do you recommend i dont click? also yeh i got confused wit vb.net VB6 16bits/2 bytes for integer 32bits/4 bytes for long VB.NET 16bits/2 bytes for short 32bits/4 bytes for integer 64bits/8 bytes for long - Bakekitsune - 18-02-2007 awesome thanks! - William - 22-02-2007 Because, longs are 32-bit numbers in VB6, while Integers are 16-bit. Since most processors now days are 32-bit, they can handle Longs much faster then integers. However, if your running a 64-bit processor, then Quads are faster then Longs. Unfortunately, VB6 have no 64-bit integers ... ![]() - Spodi - 23-02-2007 Double and Currency. :wink: - William - 23-02-2007 Double: not enough precision Currency: can't handle the maximum 64-bit values Refs: http://www.thescripts.com/forum/thread15354.html http://www.experts-exchange.com/Program ... d=21579668 http://www.devx.com/vb2themax/Tip/18308 http://en.wikipedia.org/wiki/Visual_Basic - Spodi - 23-02-2007 Quote:However, Visual Basic does provide an unusual "Currency" Data Type, which is essentially a 64-bit fixed-point number with 15 digits to the left and 4 to the right of the decimal point. Tell me how that is not 64-bit, even if it is fixed point. :wink: |