Performance Testing
===================

High Volume Tests (HVT)

This function adds random records to any table in the current database.
It takes the table name and the number of records to be added as
parameters. The liberal sprinkling of DoEvents does slow the process
down, but as you're likely to set the thing running to add thousands
of records, you'll want your PC to be free whilst the machine gets on
with it, and the DoEvents really do make your PC totally useable.

Those with several PCs can remove the DoEvents to speed up
the operation by about 50%.

I wouldn't recommend re-entering the routine whilst it is already
running, as unpredictable (you know the sort of thing) results may
occur.

Any comments and suggestions to Darren Reynolds at 100277,2270


To use:

Copy the following text, and paste it into a new module in your
database. Then open the immediate window, and type:

HVT_AddRndRecsTbl  <TableName> , <NumberToAdd>

where <TableName> is the name of the table, and <NumberToAdd> is the
number of random records you want adding.


Example:

HVT_AddRndRecsTbl "tbl Customer", 5000

This example would add 5000 records to the customers table.


Sub HVT_AddRndRecsTbl (tbName As String, RecCount As Integer)

 Dim DB As Database
 Dim TB As Table
 Dim Fields As Snapshot
 Dim RecC As Integer
 Dim ChrC As Integer
 Dim SB As String

 If RecCount < 1 Or RecCount > 100000 Then Error 5
 
 Set DB = CurrentDB()
 Set TB = DB.OpenTable(tbName)
 Set Fields = TB.ListFields()

 Waste = SysCmd(1, "Adding ...", RecCount)
 
 For RecC = 1 To RecCount
  TB.AddNew
  Fields.MoveFirst
  While Not Fields.Eof
   If (Fields.Attributes And 16) = 0 Then
      Select Case Fields.Type
       Case 1
        If Rnd > .5 Then TB(Fields.Name) = True Else TB(Fields.Name) = False
       Case 2
        TB(Fields.Name) = Int(Rnd * 256)
       Case 3
        TB(Fields.Name) = Int(Rnd * 65536 - 32768)
       Case 4
        TB(Fields.Name) = Int(Rnd * 65536 * 65536 - (32768 * 65536))
       Case 5
        TB(Fields.Name) = Rnd * 10000
       Case 6
        TB(Fields.Name) = Rnd * 10000
       Case 7
        TB(Fields.Name) = Rnd / Rnd * 10000
       Case 8
        TB(Fields.Name) = DateSerial(Rnd * 10 + 1986, Rnd * 12, Rnd * 31)
       Case 10
        SB = Chr(Rnd * 26 + 65)
        For ChrC = 1 To Rnd * Fields.Size - 1
         If Rnd < .2 Then SB = SB + " " Else SB = SB + Chr(Int(Rnd * 26 + 97))
         DoEvents
        Next ChrC
        TB(Fields.Name) = SB
       Case 12
        SB = ""
        For ChrC = 1 To Rnd * 500
         If Rnd < .2 Then SB = SB + " " Else SB = SB + Chr(Int(Rnd * 26 + 97))
         If Rnd < .05 Then SB = SB + ". " + Chr(Int(Rnd * 26 + 65))
         DoEvents
        Next ChrC
        TB(Fields.Name) = SB
      End Select
   End If
   Fields.MoveNext
   DoEvents
  Wend
  TB.Update
  Waste = SysCmd(2, RecC)
 Next RecC
 
 Fields.Close
 TB.Close
 DB.Close
 Waste = SysCmd(3)

End Sub

