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!
Use Byref or Byval? (incorrect version)ByRef arguments are 1/3 faster than Byval.
If you do not explcitly declare arguments as Byval or Byref,
VB will use ByRef as default. So if you never specify ByVal, there won't be any speed gain for you here.
Except that you can specify ByRef explicit (see other VB Fibre article)
Note: In June 2002 someone ("speedy") pointed me on an error, which has been fixed in an new post in this cateogry.
What is wrong with this one? I forgot to prefix the parameters of the sub "Byval", which is required as well. Simply saying "Test2 Byval x" is wrong. Code used:
User contributed notes:
What is wrong with this one? I forgot to prefix the parameters of the sub "Byval", which is required as well. Simply saying "Test2 Byval x" is wrong. Code used:
Calling: Code: |
With ByVal % faster than With ByRef | With ByVal (sec) | With ByRef (sec) |
27,9% | 0,257264 | 0,201177 |
33,2% | 0,264654 | 0,198650 |
28,6% | 0,257305 | 0,200032 |
34,4% | 0,264883 | 0,197073 |
32,1% | 0,261864 | 0,198252 |
User contributed notes:
Author: Tom (hurendo_kun at hotmail dot com) | Date: 13:05 31/05/2005 |
Declaring ByRef is not always possible with API calls. Something to keep in mind. |