vbAccelerator - Contents of code file: frmTest.frm

VERSION 5.00
Begin VB.Form frmIdxCollectionTest 
   Caption         =   "Index Collection Tester"
   ClientHeight    =   3405
   ClientLeft      =   5175
   ClientTop       =   2010
   ClientWidth     =   4455
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmTest.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   3405
   ScaleWidth      =   4455
   Begin VB.CommandButton cmdClear 
      Caption         =   "&Clear"
      Height          =   375
      Left            =   3120
      TabIndex        =   5
      Top             =   960
      Width           =   1215
   End
   Begin VB.TextBox txtLog 
      Height          =   2415
      Left            =   60
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   4
      Top             =   960
      Width           =   3015
   End
   Begin VB.TextBox txtSize 
      Height          =   285
      Left            =   60
      TabIndex        =   1
      Text            =   "1000"
      Top             =   300
      Width           =   2955
   End
   Begin VB.CommandButton cmdTest 
      Caption         =   "&Test"
      Height          =   375
      Left            =   3120
      TabIndex        =   0
      Top             =   60
      Width           =   1215
   End
   Begin VB.Label lblIterations 
      Caption         =   "&Results:"
      Height          =   255
      Index           =   1
      Left            =   60
      TabIndex        =   3
      Top             =   660
      Width           =   2955
   End
   Begin VB.Label lblIterations 
      Caption         =   "&Size of Array"
      Height          =   255
      Index           =   0
      Left            =   60
      TabIndex        =   2
      Top             =   60
      Width           =   2955
   End
End
Attribute VB_Name = "frmIdxCollectionTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private c As New cCollection
Private c2 As New cIndexCollection
Private c3 As New cIndexCollection2

Private Size As Long
Private Iter As Long

Private Sub Speed(ByVal sName As String, coll As Object)
Dim i As Long
Dim j As Long
   
   StartTiming
   coll.Clear
   LogTiming sName & ":Clear", EndTiming
   
   StartTiming
   For i = 1 To Size
      coll.Add i
   Next i
   LogTiming sName & ":Add", EndTiming
   
   StartTiming
   For i = 1 To Size
      j = coll.Item(i)
   Next i
   LogTiming sName & ":Read", EndTiming
   
   StartTiming
   For i = 1 To Size
      coll.Remove 1
   Next i
   LogTiming sName & ":Remove", EndTiming
   
   StartTiming
   For i = 1 To Size
      coll.Add i, 1
   Next i
   LogTiming sName & ":Insert", EndTiming
   
   StartTiming
   coll.Clear
   LogTiming sName & ":Clear", EndTiming
   
End Sub
Private Sub LogItem(ByVal sMsg As String)
   txtLog.Text = txtLog.Text & vbCrLf & sMsg
End Sub

Private Sub LogTiming(ByVal sMsg As String, ByVal lT As Long)
   LogItem lT & ":   " & sMsg
End Sub

Private Sub cmdClear_Click()
   txtLog.Text = ""
End Sub

Private Sub cmdTest_Click()
   Size = CLng(txtSize.Text)
   c2.AllocationSize = Size / 10
   c3.AllocationSize = Size / 10
   
   LogItem ""
   LogItem ""
   LogItem Size & " Items"
   LogItem "------------------------------------------------"
   Speed "Standard Collection", c
   LogItem "------------------------------------------------"
   Speed "Index Collection", c2
   LogItem "------------------------------------------------"
   Speed "Optimised Index Collection", c3
   LogItem "------------------------------------------------"
   LogItem ""

End Sub