» 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!

Less procedure calling is faster

Well, you can see it surely takes a lot time to call a sub/function. Calling the sub in every loop is around 160% slower than calling the sub once and perform the action there!

'//This sub is called 500000 times!

Code:
Public Sub TestOne() lngTemp = 100 End Sub

'//This sub is called once, and loops 500000 times in the loop

Code:
Public Sub TestTwo() Dim I As Long For I = 1 To lngIterations '//Run test lngTemp = 100 Next I End Sub

W. Proc % faster than w/h Proc W. Proc (sec) w/h Proc (sec)
137% 0,007135 0,003010
149,7% 0,007517 0,003010
167,1% 0,008040 0,003010
168,2% 0,008075 0,003011
152,4% 0,007600 0,003010


User contributed notes:

Author: Tom (hurendo_kun at hotmail dot com) Date: 05:09 23/09/2005
Also bear in mind that these subs have dual interfaces, which may adversely affect performance. If they were private, you might notice a smaller difference . . . but function calls are always slower than inline code anyway.

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