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

Always remove "Debug.Print"

Well, the results speak for themself. Always remove "Debug.Print" in final compilations. The speed increase is easy to explain: VB will still call the function, even if it's a Debug.Print in a compiled exe. Standard test:500.000 iterations, and that 5 times.

Used Code:

Code:
Public Sub TestOne() Debug.Print CallTestFunction End Sub Public Sub TestTwo() '//Debug.Print CallTestFunction End Sub Public Function CallTestFunction() As Byte CallTestFunction = CByte(10 + 20 / 3 * 5) End Function

Debug % faster than No debug Debug (sec) No debug (sec)
548,3% 0,046117 0,007114
537,6% 0,045286 0,007103
526,4% 0,045348 0,007239
559,3% 0,047021 0,007132
547,7% 0,045459 0,007018


User contributed notes:

Author: VBBR () Date: 18:03 15/03/2004
OK, I have downloaded the template and made the test with the following code:
(note: I used an EXE file)


Public Sub TestOne()
Dim result As Byte
result = CallTestFunction
Debug.Print result
End Sub

Public Sub TestTwo()
Dim result As Byte
result = CallTestFunction
'//Debug.Print result
End Sub

Public Function CallTestFunction() As Byte
CallTestFunction = CByte(10 + 20 / 3 * 5)
End Function

-------------------

And the file result.txt contained the following:


% faster 16,8 | 20,3 | -24,1 | -2,5 | -4,4
Test1|0,013659|0,014266|0,011389|0,012454|0,012021
Test2|0,011697|0,011856|0,014996|0,012775|0,012572

----------------

Wich means the test of the site is misleading, because it doesn't even call the function in TestTwo... So the time is just to call the function.

Hope this helps to improve the site.
Note that my results may be wrong. Better test the code yourself.

Author: Almar Joling () Date: 12:03 20/03/2004
For visitors: Please check out this forum post about this. :)

Author: VBBR () Date: 18:03 27/03/2004
Yeah, check the post, it's a lot better explained there...

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