Testing performance of VB 5.0 FlexGrid, Grid32 and VB 3.0 Grid 
Author Message
 Testing performance of VB 5.0 FlexGrid, Grid32 and VB 3.0 Grid

Sorry for the lengthy post, but I got caught up in this little
experiment.

In case anyone else is interested in the performance of the grids, I
tested the Grid32 against the Flexgrid.  I also tried the program in
VB 3.0.  

Flexgrid gave the following results:

Using Row, Col and Text:                        10.5 s
Using R, C and Text but hidden:                 7.8
Using AddItem                                   16.5
Using TextMatrix (or TextArray)                 2.1

Grid32:

Using Row, Col and Text:                        11.2 s
Using R, C and Text but hidden:                 8.9
Using AddItem                                   5.3

VB 3.0 MSGrid

Using Row, Col and Text:                        3.4 s
Using R, C and Text but hidden:                 2.1
Using AddItem                                   2.5

Grid32 is obviously a rather inefficient version of the original grid.
The flexgrid is OK, but only if you use the TextMatrix or TextArray
(they seem about equal in performance.)  If you combine hiding the
grid with using TextMatrix, you will get the best performance.

It still burns me that 16 bit programs run so much faster on
supposedly 32 bit OS than 32 bit progs, but whattayagonnado.

AddItem gave me problems in both Grid32 and VB 3.0 Grid.  When I used
Str(mMatrix(i, 1)) & Chr$(9) & Str(mMatrix(i, 2)) ... Where mMatrix
was an array of random singles, the grid would only put in the numbers
sporadically (cmdGridFail in source below.)  The only way I found
around this was to use text values or integer values instead of the
random singles I was using before.  Then it would load them reliably.

Question:  Anyone know why the non-integer values would fail to load
reliably with AddItem in the Grid.VBX and Grid32.OCX ??

Source for the experiment follows . . .

Option Explicit
Private mMatrix(1 To 1000, 1 To 6) As Single
Private strText As String

Private Sub cmdFGTextMatrix_Click()

    Dim sngStart As Single
    Dim i As Integer, j As Integer

    grdMatrix.Clear
    sngStart = Timer

    For i = 1 To 1000
        For j = 1 To 6
             grdMatrix.TextMatrix(i - 1, j - 1) = strText
        Next j
     Next i
    cmdFGTextMatrix.Caption = Format(Timer - sngStart)
    Beep

End Sub

Private Sub cmdGridFail_Click()
    Dim i As Integer, j As Integer
    Dim strTemp As String
    Dim sngStart As Single

    For i = 1 To 1000
        grdMatrix2.Row = i - 1
        For j = 1 To 6
            grdMatrix2.Col = j - 1
            grdMatrix2.Text = ""
        Next j
    Next i

    grdMatrix2.Rows = 1
    grdMatrix2.Refresh

    sngStart = Timer

    For i = 1 To 1000
        strTemp = Str(mMatrix(i, 1)) & Chr(9) & Str(mMatrix(i, 2)) &
Chr(9) & Str(mMatrix(i, 3)) & Chr(9) & Str(mMatrix(i, 4)) & Chr(9) &
Str(mMatrix(i, 5)) & Chr(9) & Str(mMatrix(i, 6))
        grdMatrix2.AddItem strTemp
    Next i
    Beep
    cmdGridFail.Caption = Format(Timer - sngStart)
End Sub

Private Sub cmdGridRCT_Click()
    Dim i As Integer, j As Integer
    Dim sngStart As Single

    For i = 1 To 1000
        grdMatrix2.Row = i - 1
        For j = 1 To 6
            grdMatrix2.Col = j - 1
            grdMatrix2.Text = ""
        Next j
    Next i

    sngStart = Timer

    For i = 1 To 1000
        grdMatrix2.Row = i - 1
        For j = 1 To 6
            grdMatrix2.Col = j - 1
            grdMatrix2.Text = strText
        Next j
    Next i
    Beep
    cmdGridRCT.Caption = Format(Timer - sngStart)
End Sub

Private Sub cmdFGRowColText_Click()
    grdMatrix.Clear
    Dim sngStart As Single
    Dim i As Integer, j As Integer
    sngStart = Timer

    For i = 1 To 1000
        grdMatrix.Row = i - 1
        For j = 1 To 6
            grdMatrix.Col = j - 1
            grdMatrix.Text = strText
        Next j
    Next i
     Beep
   cmdFGRowColText.Caption = Format(Timer - sngStart)
End Sub

Private Sub Form_Load()
    Dim i As Integer, j As Integer

    For i = 1 To 1000
        For j = 1 To 6
            'Note if I make this into an integer value then AddItem
doesn't fail.
            mMatrix(i, j) = Rnd
        Next j
    Next i

    strText = "Hello"
    Beep
End Sub
Private Sub cmdFGHidden_Click()
    grdMatrix.Visible = False
    grdMatrix.Clear
    Dim sngStart As Single
    Dim i As Integer, j As Integer

    sngStart = Timer

    For i = 1 To 1000
        grdMatrix.Row = i - 1
        For j = 1 To 6
            grdMatrix.Col = j - 1
            grdMatrix.Text = strText
        Next j
    Next i
    cmdFGHidden.Caption = Format(Timer - sngStart)
    grdMatrix.Visible = True
    Beep
End Sub

Private Sub cmdFGAddItem_Click()

    grdMatrix.Clear
    grdMatrix.Rows = 1
    Dim sngStart As Single
    Dim i As Integer, j As Integer

    sngStart = Timer

    For i = 1 To 1000
        grdMatrix.AddItem strText & Chr(9) & strText & Chr(9) &
strText & Chr(9) & strText & Chr(9) & strText & Chr(9) & strText
    Next i
    cmdFGAddItem.Caption = Format(Timer - sngStart)
    Beep
End Sub

Private Sub cmdGridHidden_Click()
    Dim i As Integer, j As Integer

    For i = 1 To 1000
        grdMatrix2.Row = i - 1
        For j = 1 To 6
            grdMatrix2.Col = j - 1
            grdMatrix2.Text = ""
        Next j
    Next i

    Dim sngStart As Single
    grdMatrix2.Visible = False

    sngStart = Timer

    For i = 1 To 1000
        grdMatrix2.Row = i - 1
        For j = 1 To 6
            grdMatrix2.Col = j - 1
            grdMatrix2.Text = strText
        Next j
    Next i
    grdMatrix2.Visible = True
    Beep
    cmdGridHidden.Caption = Format(Timer - sngStart)
End Sub

Private Sub cmdGridAddItem_Click()
    Dim i As Integer, j As Integer
    Dim strTemp As String

    grdMatrix2.Rows = 1

    Dim sngStart As Single

    sngStart = Timer

    For i = 1 To 1000
        strTemp = strText & Chr(9) & strText & Chr(9) & strText &
Chr(9) & strText & Chr(9) & strText & Chr(9) & strText
        grdMatrix2.AddItem strTemp
    Next i
    Beep
    cmdGridAddItem.Caption = Format(Timer - sngStart)
End Sub
Private Sub cmdFGTextArray_Click()

    grdMatrix.Clear
    grdMatrix.Rows = 1000
    Dim sngStart As Single
    Dim i As Integer, j As Integer

    sngStart = Timer

    For i = 1 To 1000
        For j = 1 To 6
            grdMatrix.TextArray((i - 1) * 6 + (j - 1)) = strText
        Next j
    Next i
    cmdFGTextArray.Caption = Format(Timer - sngStart)
    Beep
End Sub

Paul Hewson  paulh(a)vif.*Delete*This*.com
-------------------------------------------
  e-mail altered to foil auto-spammers  

-------------------------------------------
Oh bother, said Pooh, as the police closed in.



Mon, 12 Nov 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0

2. Moving from VB 3.0 to VB 5.0

3. Converting from VB 3.0 -> VB 5.0

4. converting code from VB 3.0 to VB 5.0

5. Upgraded from VB 3.0 to VB 5.0 - have questions

6. VB 3.0 to VB 5.0

7. VB 5.0 vs VB 3.0 Form Editor

8. Help : Converting VB 3.0 Program to VB 5.0

9. VB 3.0 to VB 5.0 program

10. Conversion from VB 3.0 to VB 5.0

11. VB 3.0 in VB 5.0

12. conversion from vb 3.0 to vb 5.0

 

 
Powered by phpBB® Forum Software