Site
News
Files Visual Basic
Strings
Math
General
Properties
Memory
Methods Search
Testing Inline ASM-VB
Strings
Math
General
Memory Search
Using inline ASM
Submit!
News
Files Visual Basic
Strings
Math
General
Properties
Memory
Methods Search
Testing Inline ASM-VB
Strings
Math
General
Memory Search
Using inline ASM
Submit!
Arrays: Temporary variablesWell no doubt about it. Temporary variables are going to speed up your program.
I have to say that I had to wait longer than expect to complete this routine.
Anyway, if you're often pointing to an array, you've definetly got to use temporary values.
Check the source code for an example. Note that I've done the test 5 times,
but there was only 1 main iteration, cause the For...Next loops where long enough.
Also note that in the first test without the temporary variable, I didn't declare the "lngTemp" variable.
We didn't use it there, so no extra variable declaration.
Used code:
User contributed notes:
Code: |
No temp var % faster than Temp var | No temp var (sec) | Temp var (sec) |
49,8% | 23,928901 | 15,979177 |
49,8% | 23,919381 | 15,963122 |
48,5% | 23,946439 | 16,122013 |
48,4% | 23,893372 | 16,103921 |
48,9% | 23,896261 | 16,050374 |
User contributed notes:
Author: Comintern () | Date: 22:03 15/03/2005 |
This is almost certainly caused by cache misses. The temp variables would fit in the cache, whereas the whole array would not. You might want to check with a smaller array and see if you still get the same results. | |
Author: Tom (hurendo_kun at hotmail dot com) | Date: 16:06 08/06/2005 |
Then I guess the lesson here is to use temp vars with larger arrays. ;) |