Announcement

Collapse
No announcement yet.

Does compiler pre compile function constants?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does compiler pre compile function constants?

    x$ = chr$(0, 0, 0, 0, &HC0, 0, 0, 0, 0, 0, 0, &H46)

    Does the compiler pre-compile the chr$ function, since all parms are constants,
    or does the chr$ execute at run time?


    ------------------
    Thanks,

    John Kovacich
    Thanks,

    John Kovacich
    Ivory Tower Software

  • #2
    99,99% sure that chr is executing in run-time.
    Change j in CHR to 57: times remain the same.
    But for me was surprise that difference is enough small (10-20%).
    Bravo, Bob
    Code:
    #Compile Exe
    #Register None
    Function PbMain
     Dim x As String * 11, i As Long, j As Long, t1 As Single, t2 As Single, t3 As Single
     
     t1 = Timer
     For i = 1 To 100000
        For j = 0 To 9
           x = Chr$(48, 49, 50, 51, 52, 53, 54, 55, 56, j)
        Next
     Next
     
     t2 = Timer
     For i = 1 To 1000000
        x = "0123456789"
     Next
     
     t3 = Timer
     MsgBox "CHR = " + Format$(t2-t1, "#.##"),, Format$(t3 - t2, "#.##")
    End Function
    ------------------
    E-MAIL: [email protected]

    Comment

    Working...
    X