» Home » VB Fibre
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!

Specify ByRef explictly

A very little speed increase. I expected a larger increase... Anyway, it's always better to declare arguments byval or byref explicitly. You can then see how values are passed, and see if it returns anything directly. I'm not sure if it's worthy to change all your subs and functions to Byref, because the speed increase ain't that much.

Code used:

Code:
Public Sub TestOne(lngValue1 As Long, strString1 As String, bByte1 As Byte) Dim I As Long I = I + 1 End Sub Public Sub TestTwo(ByRef lngValue1 As Long, ByRef strString1 As String, ByRef bByte1 As Byte) Dim I As Long I = I + 1 End Sub

Without Byref % faster than With Byref Without Byref (sec) With Byref (sec)
2,4% 0,196016 0,191442
1,1% 0,193253 0,191196
2% 0,193553 0,189785
0,7% 0,192911 0,191511
0,6% 0,192012 0,190801


User contributed notes:

Author: Comintern () Date: 22:03 15/03/2005
This test might have some validity if you actually used the variables that you passed in the function. As written, no memory reads would be done by the called function. Also, default means exclusive of. Try compiling each function in a different .exe and checksumming them. I'd bet bank that they are exactly the same.

Author: Tom (hurendo_kun at hotmail dot com) Date: 19:10 21/10/2005
Any performance difference here has to be hiccups in the system, because you get the same code whether or not you declare ByRef. Declaring ByVal, on the other hand, will result in faster functions.

Add user-note
Author:
E-mail (optional):
Anti spam, please enter 'ok' without quotes:
Comment: