Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reduce amount of string comparisons for handling packets
#1
AddressOf() just gives you the pointer to the memory where the functions that handles the packets are. Pointers are veeeeery fast, I mean, very very very much faster than any comparison. I'm almost sure that this system is much faster than any other, and that's why I use it xD
Reply
#2
Nono, VB6 has a switch, its named select:
Code:
Select Case Statement
      

Executes one of several groups ofstatements, depending on the value of anexpression.

Syntax

Select Case testexpression
[Case expressionlist-n
[statements-n]] ...
[Case Else
[elsestatements]]

End Select

The Select Case statement syntax has these parts:

Part Description
testexpression Required. Anynumeric expression orstring expression.
expressionlist-n Required if a Case appears. Delimited list of one or more of the following forms: expression, expression To expression, Is comparisonoperator expression. The Tokeyword specifies a range of values. If you use the To keyword, the smaller value must appear before To. Use the Is keyword withcomparison operators (except Is and Like) to specify a range of values. If not supplied, the Is keyword is automatically inserted.
statements-n Optional. One or more statements executed if testexpression matches any part of expressionlist-n.
elsestatements Optional. One or more statements executed if testexpression doesn't match any of the Case clause.


Remarks

If testexpression matches any Case expressionlist expression, the statements following that Case clause are executed up to the next Case clause, or, for the last clause, up to End Select. Control then passes to the statement following End Select. If testexpression matches an expressionlist expression in more than one Case clause, only the statements following the first match are executed.

The Case Else clause is used to indicate the elsestatements to be executed if no match is found between the testexpression and an expressionlist in any of the other Case selections. Although not required, it is a good idea to have a Case Else statement in your Select Case block to handle unforeseen testexpression values. If no Case expressionlist matches testexpression and there is no Case Else statement, execution continues at the statement following End Select.

You can use multiple expressions or ranges in each Case clause. For example, the following line is valid:

Case 1 To 4, 7 To 9, 11, 13, Is > MaxNumber

Note   The Is comparison operator is not the same as the Is keyword used in the Select Case statement.

You also can specify ranges and multiple expressions for character strings. In the following example, Case matches strings that are exactly equal to everything, strings that fall between nuts and soup in alphabetic order, and the current value of TestItem:

Case "everything", "nuts" To "soup", TestItem

Select Case statements can be nested. Each nested Select Case statement must have a matching End Select statement.
Reply
#3
Verr or Spodi already said (I forget who)

That there's no real speed difference between Cases and Conditionals.
Reply
#4
While we are sort of on the subject.. Is taking the time to convert to byte arrays really worth all the work?
Reply
#5
I only noticed it when I was wondering why the Ubound of parse was 1 higher, and realized that End_char was the last one.
Reply
#6
If it is performance you are after, theres many other places you should be looking before dealing with this.

One thing I have come to realize, though, is that companies like Mac take a much better approach - get things completed quickly with just the minimalist features and very stable. From there, you can expand on the features and worry about performance. Even if you don't release it until the very end, its a hell of a lot easier to test something if it is slow but works in comparison to fast and broken.
Reply
#7
With the most optimized code, you may take it from really slow to really slow - 1. You can't speed up something just by cleaning up the code around it. Simple file I/O like string reading along with variable-location I/O like the INI reading is very slow. Period. It has nothing to do with the code used to do it, its just the method itself. With INIs, you are scanning a file up and down looking for the value before you parse it and read it. With string file I/O, its not as bad since it is a linear read, but it still has to convert the structure to a string, and you have to parse the values of the string yourself. Binary is just the most efficient method for linear file reading - nothing can beat it, and I doubt anything ever will, unless the memory and/or file structure is changed. Heck, its probably even a hell of a lot faster if you're reading a file in the wrong endian even.
Reply
#8
Spodi Wrote:With the most optimized code, you may take it from really slow to really slow - 1. You can't speed up something just by cleaning up the code around it. Simple file I/O like string reading along with variable-location I/O like the INI reading is very slow. Period. It has nothing to do with the code used to do it, its just the method itself. With INIs, you are scanning a file up and down looking for the value before you parse it and read it. With string file I/O, its not as bad since it is a linear read, but it still has to convert the structure to a string, and you have to parse the values of the string yourself. Binary is just the most efficient method for linear file reading - nothing can beat it, and I doubt anything ever will, unless the memory and/or file structure is changed. Heck, its probably even a hell of a lot faster if you're reading a file in the wrong endian even.

-1 = faster, even if it's barely anything. Smile
Reply
#9
I think you missed the point that it is still really really slow. :wink: Time would be much better spent actually making the game so its performance can actually be put to use. If I wrote a renderer that puts Farcry to shame that could run at 100 FPS on a 233mhz comp, no one would care if there was no content for it to draw.
Reply
#10
The point was that you could have the most powerful, faster, optimized engine, but without a game to play it with, it's useless.
Reply
#11
DFA Wrote:100 FPS because a PC with a 233MHZ CPU will have a monitor and gfx card that supports 100Hz refresh rate?

Don't need a 100Hz refresh rate to have 100 FPS. You'd only need it to display 100 FPS. You can draw as many frames as you want if you just discard instead of waiting for the vertical sync. Its not like drawing faster than you're refreshing is a new concept or anything.
Reply
#12
Cough

[Image: erhm.png]
Reply
#13
Rezeyu Wrote:Cough

[Image: erhm.png]
[Image: db680-cat-ownage-imminent.jpg]
Reply
#14
Eh? I never said there WAS no support for 100Hz+ frequencies, I just said you don't need one. Of course theres graphic cards and monitors that support it, though how useful it is is another story.
Reply
#15
I was replying to DFA.

XD
Reply
#16
Damn, I knew I was going to be told I was misreading that.

Bad Spodi, bad!
Reply
#17
Spodi Wrote:Damn, I knew I was going to be told I was misreading that.

Bad Spodi, bad!

Someone needs to go spend all their donated dollars on alcohol :D
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)