Game Development Reference
In-Depth Information
low-level optimizations manually. Current compilers on the market are quite
intelligent when it comes to low-level optimizations, even smarter than you. Just
make sure that you enable compiler optimizations when building a final release so
that the compiler can work its magic. Be sure to test your application in release
mode because preprocessor symbols and conditionally compiled function calls can
perform unexpectedly when executed in a different compilation mode. Certain
bugs may be masked in debug mode and only appear in an optimized compilation.
The optimizations that you should be concerned with are high-level, such as mem-
ory allocation, network traffic, and using inappropriate data structures and algo-
rithms. Make sure that you profile your code before attempting to optimize. It is a
waste of time to incorrectly guess where code is suffering from poor performance
and attempt to optimize in an area that does not need it.
Use code analysis tools such as FxCop to help identify performance bottlenecks.
Some bottlenecks are very hard to identify without a robust tool to help you.
Lastly, pass your assemblies through a commercial obfuscator. The main purpose
of an obfuscator is to make it difficult to decompile your application by mangling
your private and internal type and variable names, but some obfuscators can
increase performance by a slight amount through shorter names and optimized
memory layouts.
String Comparison
Pretty much every application performs comparisons between strings, with the
variant being the number of comparisons performed. String equality can be
defined as two strings with the identical sequence of characters, also known as
binary equality . This type of string comparison works for most situations, but
binary equality does not suffice when multiple locales are used, or case sensitivity
matters. The term logical equality is used to describe two strings that are equiva-
lent despite binary differences.
The System.String data type of the .NET framework provides numerous ways to
store and manipulate string data, including methods of performing binary and
logical equality comparisons. Three methods exist that provide the ability to check
for binary equality: two instance methods and one static method. The first
instance method is strongly typed to accept a string parameter, and the other
instance method overrides the Equals method inherited from System.Object .The
overridden method is not recommended unless you are comparing more than just
strings, because this method suffers a performance penalty by needing to perform
Search Nedrilad ::




Custom Search