DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 12 of 12

Thread: debug.print in FINAL EXE

  1. #1
    Ray Marsh Guest

    debug.print in FINAL EXE

    I have read from a few web sites that leaving debug.print in the final
    EXE of a Visual Basic application can slow down the program. Is this
    true?

    thanks



  2. #2
    Veign Guest

    Re: debug.print in FINAL EXE

    No...Comments and Debug statements are removed when the application is
    compiled.

    --
    Veign
    Designing Solutions
    www.veign.com
    VB Code Samples & Projects
    www.veign.com/information/info_main.html


    "Ray Marsh" <ramarsh@attbi.com> wrote in message
    news:u9ki5ushpo1blgafqqdnrisqd7u8qda8mk@4ax.com...
    > I have read from a few web sites that leaving debug.print in the final
    > EXE of a Visual Basic application can slow down the program. Is this
    > true?
    >
    > thanks
    >
    >




  3. #3
    Anthony Jones Guest

    Re: debug.print in FINAL EXE

    Actually, Debug.Print statements are not removed.

    Slap the following in Form1 of a standard exe and compile. You will see
    that the message box still pops up.

    Private Sub Form_Load()
    Debug.Print SomeFunc()
    End Sub

    Private Function SomeFunc() As String
    MsgBox "Hello"
    SomeFunc = "Boo"
    End Function


    --
    Anthony Jones
    Nuesoft Ltd



  4. #4
    Dean Earley Guest

    Re: debug.print in FINAL EXE

    > Actually, Debug.Print statements are not removed.
    >
    > Slap the following in Form1 of a standard exe and compile. You will see
    > that the message box still pops up.
    >
    > Private Sub Form_Load()
    > Debug.Print SomeFunc()
    > End Sub
    >
    > Private Function SomeFunc() As String
    > MsgBox "Hello"
    > SomeFunc = "Boo"
    > End Function


    It removes the debug.print bit of it so when it is compiled it will be exactly the same as:

    Private Sub Form_Load()
    SomeFunc()
    End Sub

    --
    Dean Earley (dean.earley@icode.co.uk)
    Assistant Developer

    iCode Systems



  5. #5
    Anthony Jones Guest

    Re: debug.print in FINAL EXE

    >It removes the debug.print bit of it

    Do we no this for sure or is it simply that there is no immediate window to
    display the results?
    Does a falling tree make a noise when there is no one there to hear it? :-)

    Try it with Debug.assert. In this case SomeFunc is never called by the
    compilied Exe (although the compilier complains if it's not present).

    --
    Anthony Jones
    Nuesoft Ltd



  6. #6
    Dean Earley Guest

    Re: debug.print in FINAL EXE

    I think someone did a test of this and compared the machine code generated. Sadly, I cant remember who it was.

    --
    Dean Earley (dean.earley@icode.co.uk)
    Assistant Developer

    iCode Systems
    "Anthony Jones" <anthony.jones@nonuesoft.spamco.uk> wrote in message news:3c596aa0$1@10.1.10.29...
    > >It removes the debug.print bit of it

    >
    > Do we no this for sure or is it simply that there is no immediate window to
    > display the results?
    > Does a falling tree make a noise when there is no one there to hear it? :-)
    >
    > Try it with Debug.assert. In this case SomeFunc is never called by the
    > compilied Exe (although the compilier complains if it's not present).
    >
    > --
    > Anthony Jones
    > Nuesoft Ltd
    >
    >




  7. #7
    Joe \Nuke Me Xemu\ Foster Guest

    Re: debug.print in FINAL EXE

    "Anthony Jones" <anthony.jones@nonuesoft.spamco.uk> wrote in message <news:3c59583b@10.1.10.29>...

    > Actually, Debug.Print statements are not removed.
    >
    > Slap the following in Form1 of a standard exe and compile. You will see
    > that the message box still pops up.
    >
    > Private Sub Form_Load()
    > Debug.Print SomeFunc()
    > End Sub
    >
    > Private Function SomeFunc() As String
    > MsgBox "Hello"
    > SomeFunc = "Boo"
    > End Function


    What happens if you modify the line to,

    Debug.Print SomeFunc() \ 0

    Will the EXE still puke and die? In VB5 EE SP3 at least, even though
    functions are still called, the expression as a whole isn't evaluated.

    --
    Joe Foster <mailto:jlfoster%40znet.com> Got Thetans? <http://www.xenu.net/>
    WARNING: I cannot be held responsible for the above They're coming to
    because my cats have apparently learned to type. take me away, ha ha!



  8. #8
    Jon Oliver Guest

    Re: debug.print in FINAL EXE

    "Joe "Nuke Me Xemu" Foster" <joe@bftsi0.UUCP> wrote in message
    news:3c5986eb@10.1.10.29...

    > What happens if you modify the line to,
    >
    > Debug.Print SomeFunc() \ 0
    >
    > Will the EXE still puke and die? In VB5 EE SP3 at least, even

    though
    > functions are still called, the expression as a whole isn't

    evaluated.

    No error will be generated -- indeed this is a means of writing
    an IsInIDE() function.



  9. #9
    Michael Culley Guest

    Re: debug.print in FINAL EXE

    Dean,

    Try this, the results are quite interesting. Create the project as below,
    compile it and run it. The titlebar will show the address of function A and
    function B. Notice anything strange?

    So the debug.prints are definately removed

    --
    Michael Culley
    www.vbdotcom.com



    Create a std exe project and put this code in Form1

    Private Sub Form_Load()
    Me.Caption = Hex$(GimmeAdd(AddressOf A)) & " " & Hex$(GimmeAdd(AddressOf
    B))
    End Sub

    Private Function GimmeAdd(ByVal Value As Long) As Long
    GimmeAdd = Value
    End Function


    Add a module and put this code in it

    Function A() As Long
    Debug.Print C
    A = 456
    End Function

    Function B() As Long
    C
    B = 456
    End Function

    Function C() As Long
    C = 789
    End Function

    --
    Michael Culley
    www.vbdotcom.com


    "Dean Earley" <dean.earley@icode.co.uk> wrote in message
    news:3c596d1a$1@10.1.10.29...
    > I think someone did a test of this and compared the machine code

    generated. Sadly, I cant remember who it was.
    >
    > --
    > Dean Earley (dean.earley@icode.co.uk)
    > Assistant Developer
    >
    > iCode Systems
    > "Anthony Jones" <anthony.jones@nonuesoft.spamco.uk> wrote in message

    news:3c596aa0$1@10.1.10.29...
    > > >It removes the debug.print bit of it

    > >
    > > Do we no this for sure or is it simply that there is no immediate window

    to
    > > display the results?
    > > Does a falling tree make a noise when there is no one there to hear it?

    :-)
    > >
    > > Try it with Debug.assert. In this case SomeFunc is never called by the
    > > compilied Exe (although the compilier complains if it's not present).
    > >
    > > --
    > > Anthony Jones
    > > Nuesoft Ltd
    > >
    > >

    >
    >




  10. #10
    Michael Culley Guest

    Re: debug.print in FINAL EXE

    This is an alternate method, which avoids the problem of having 'break on
    all error' set

    Public Property Get IsDev() As Boolean
    Debug.Assert SetTrue(IsDev) Or True
    End Property
    Private Function SetTrue(Value As Boolean) As Boolean
    Value = True
    End Function

    --
    Michael Culley
    www.vbdotcom.com


    "Jon Oliver" <joliver@no.spam.maam.com> wrote in message
    news:3c5991e4$1@10.1.10.29...
    > "Joe "Nuke Me Xemu" Foster" <joe@bftsi0.UUCP> wrote in message
    > news:3c5986eb@10.1.10.29...
    >
    > > What happens if you modify the line to,
    > >
    > > Debug.Print SomeFunc() \ 0
    > >
    > > Will the EXE still puke and die? In VB5 EE SP3 at least, even

    > though
    > > functions are still called, the expression as a whole isn't

    > evaluated.
    >
    > No error will be generated -- indeed this is a means of writing
    > an IsInIDE() function.
    >
    >




  11. #11
    Dean Earley Guest

    Re: debug.print in FINAL EXE

    > Try this, the results are quite interesting. Create the project as below,
    > compile it and run it. The titlebar will show the address of function A and
    > function B. Notice anything strange?
    >
    > So the debug.prints are definately removed


    What has that done then?

    It looks like its merged them or just rewritten them as constants because they have the same constant result.

    --
    Dean Earley (dean.earley@icode.co.uk)
    Assistant Developer

    iCode Systems



  12. #12
    Michael Culley Guest

    Re: debug.print in FINAL EXE

    The compiler has said to itself "these 2 functions are exactly the same so
    I'll just make one function and use the same address". So basically
    debug.print C is the same as just C, so the debug.prints are eliminated.

    --
    Michael Culley
    www.vbdotcom.com


    "Dean Earley" <dean.earley@icode.co.uk> wrote in message
    news:3c5a5bfd$1@10.1.10.29...
    > > Try this, the results are quite interesting. Create the project as

    below,
    > > compile it and run it. The titlebar will show the address of function A

    and
    > > function B. Notice anything strange?
    > >
    > > So the debug.prints are definately removed

    >
    > What has that done then?
    >
    > It looks like its merged them or just rewritten them as constants because

    they have the same constant result.
    >
    > --
    > Dean Earley (dean.earley@icode.co.uk)
    > Assistant Developer
    >
    > iCode Systems
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center