|
|
|||
| H o m e | |||
|
|
O p t i m i z a t i o n - D a t a T y p e W i d t h By Michael McIntyre
Where possible in your code use data types that are 32 bits wide to maximize the performance in your .NET application. The native data width of the .NET runtime, current computers, and current operating systems is 32 bits.
Using the most efficient data type will have a negligible effect on performance when used in a simple statement. But, inside a loop or frequently called procedure the increase in efficiency can be dramatic.
The most efficient types in VB.NET, in order of efficiency are:
1. Integer 2. Long 3. Short 4. Byte
Because the Integer data type is 32 bits wide it is most efficient. A Short data type is less efficient performance wise even though its size - data width - is less than that of an Integer.
If you need decimal values the most efficient data types in VB.NET, in order of efficiency are:
1. Double 2. Single 3. Decimal
Double is most efficient for decimal values because the floating-point processors of current platforms perform all operations in double precision.
A smart .NET programmer learns where integral (Integer, Long, Short, and Byte) data types can be used in place of fractional types. For example, when you have a choice of units when representing the size of an image, you may be able to use Pixels instead of Inches or Centimeters. The number of pixels in an image is always a whole number so you can store pixels in an Integer. Inches and Centimeters are typically fractional. In a large or very repetitive drawing operation the difference in performance between integral and fractional data types can be very large.
|
||
|
Copyright © 2001-2003 aZ Software Developers. All rights reserved. |
|||