Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1448

Friend in Class1-VB6 calls multiple methods to run speed test

$
0
0
Optimized for vb6 running speed
call function Fastest c=Bas_Sum(a,b)
call Friend is quick than "public function",The operating speed is 4.6 times faster
-----------
Class_OBJ 452.38 (dim a as class1 ,call a.Sum(**))
Class_Friend_Ptr 70.38
Class_Friend 80.65(call a.FrinedSum)
----------
call objptr like stdcall :cUniversalDLLCalls.CallFunction_COM(***),The operating speed is 1 times faster(up 100%)

Pointer call function address of COM object:
call com dll(activex.dll).FrinedSum(***), Speed increased by 5.6 times
(465.77 pk 70.57)
It takes 827 seconds to call activex.exe, which is 14000 times more than the time to directly call the process

Unfortunately, this seems to be no way. It is like operating the "EXCEL.APPLICATION" object in VB6 and controlling the third-party process of excel.exe. It is very slow. Unless running in EXCEL VBA, it is also about 4 times slower than VB6, but it is slower than ActiveX.EXE with 14,000 times is still much better.
This is just a theoretical number and has not been tested specifically, but calling activex.exe is really slow.
=====================
method1:Friend Function FrinedSum(ByRef a As Long, ByRef b As Long) As Long
method2:Public Function Sum(ByRef a As Long, ByRef b As Long) As Long
method3:Public Function Bas_Sum in moudle.bas
method4:Public Sub BasSub_Sum in moudle.bas

com dll=(class1.cls in comdll1.dll)
actexe=(class1.cls in activex1.exe)
class1.cls in same vb project
call function sum(a,b)
call sub sum(a,b,returnvalue)
The main methods of testing

Code:

TestCount = 1000000*20
Sub Test_Exe1_MySum_object(id As Long)
dim Exe1 as new activex1_exe.Class1
Dim i As Long
For i = 1 To TestCount
    a1 = 3
    b1 = 4
    'Call Exe1_MySum2(ThisExe1, a1, b1, Ret) 'by objptr stdcall
    Ret = Exe1.Sum(a1, b1)
next
end sub

Public Function Bas_Sum(ByRef a As Long, ByRef b As Long) As Long 'method3
 
Bas_Sum = a + b
a = a * a
b = b * b
End Function
Public Sub BasSub_Sum(ByRef a As Long, ByRef b As Long, ByRef Value1 As Long) 'method4
 
Value1 = a + b
a = a * a
b = b * b
End Sub

class1.cls
Code:

Option Explicit
 Public Event Sum2(ByRef id As Long)   

Public Sub Test()
MsgBox "ComDll.lib-test"
End Sub
Public Sub TEST2()
MsgBox "ComDll.lib-test2"
End Sub
Public Function Sum(ByRef a As Long, ByRef b As Long) As Long
 
Sum = a + b
a = a * a
b = b * b
End Function
 
Public Sub test3()
Dim i As Long
Dim v2 As Long
Dim V1 As Long
For i = 1 To 1
V1 = i
v2 = i
 
RaiseEvent Sum2(v2)
 
Next
End Sub
Friend Function FrinedSum(ByRef a As Long, ByRef b As Long) As Long
 
MsgBox "FrinedSum"
FrinedSum = a + b
a = a * a
b = b * b
End Function
Friend Function FrinedSum2(ByRef a As Long, ByRef b As Long) As Long
 
MsgBox "Class_FrinedSum2"
FrinedSum2 = a + b
a = a * a
b = b * b
End Function


Viewing all articles
Browse latest Browse all 1448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>